locked
Binding Dynamic Controls IN MVVM

    Question

  • Hi All,

    Am Developing Win 8 App, Which Includes Generation Of dynamic Controls Inside a grid,

    I have achieved the same in Code Behind File,

    Now we are migrating our project in MVVM Light,

    How can i achieve the same in MVVM?

    I need to generate Different Controls inside a Grid and arrange them accordingly.

    Any suggestion would be of great help.

    Thanks

    Arjun.M


    Arjun

    Wednesday, March 12, 2014 9:01 AM

Answers

  • Hi,

    I do not very familiar with MVVM. But there are some links below you can refer to, may be them can help you:

    http://stackoverflow.com/questions/11095189/adding-controls-dynamically-in-wpf-mvvm

    http://stackoverflow.com/questions/20064821/generate-controls-dynamically-in-view-for-mvvm-windows-8

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, March 13, 2014 3:41 AM
  • The view model should know nothing about any UI controls so if you are generating these controls in the code-behind of the view, you should keep doing so even if your application uses the MVVM pattern.

    The view model is reponsible for the presentation logic and state of your application, for example to store data objects in a collection and to decide what happens when you click a button. Keeping any UI related code, which for example creates controls, expresses animations or modifies the layout, in the view does not break the pattern.

    Thursday, March 13, 2014 1:53 PM

All replies

  • Hi,

    I do not very familiar with MVVM. But there are some links below you can refer to, may be them can help you:

    http://stackoverflow.com/questions/11095189/adding-controls-dynamically-in-wpf-mvvm

    http://stackoverflow.com/questions/20064821/generate-controls-dynamically-in-view-for-mvvm-windows-8

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Thursday, March 13, 2014 3:41 AM
  • The view model should know nothing about any UI controls so if you are generating these controls in the code-behind of the view, you should keep doing so even if your application uses the MVVM pattern.

    The view model is reponsible for the presentation logic and state of your application, for example to store data objects in a collection and to decide what happens when you click a button. Keeping any UI related code, which for example creates controls, expresses animations or modifies the layout, in the view does not break the pattern.

    Thursday, March 13, 2014 1:53 PM