tags:

views:

21

answers:

1

Hi, I want to add Controls dynamically from ViewModel. I have to add Button and Textbox dynamically to the Grid. In the ViewModel constructor call I need to add the controls. I am not getting how to get the Grid control reference in my ViewModel. Can anybody help me on this? Thanks in advance

+3  A: 

That would be the wrong way. Your ViewModel should not be directly aware of the View.

You could create a UserControl (or maybe a template) for your Button+TextBox and bind it to a property (or List) of a specialized ViewModel on your main ViewModel.

Henk Holterman