开发者

Adding controls dynamically to the Grid in the constructor from ViewModel

开发者 https://www.devze.com 2023-01-13 05:29 出处:网络
I want to add Controls dynamically from ViewModel. I have to add Button and Textbox dynamically to the Grid. In the ViewModel construct开发者_开发问答or call I need to add the controls. I am not getti

I want to add Controls dynamically from ViewModel. I have to add Button and Textbox dynamically to the Grid. In the ViewModel construct开发者_开发问答or 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消