How can I add dynamically a grid into another grid? I can’t do this:
myGrid.Children.Add(dg);
Because I don’t have the instance of this grid – I’m using MVVM.
Please Help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume, since you mention MVVM, that you want to accomplish this from your View Model?
In that case my suggestion is to send a message from the View Model to the View.
In the View you add a subscription to this message and add the Grid from there.
You could do it something like this, in its most simple form. This would be using the excellent MVVM Light framework:
ViewModel.cs:View.xaml.cs: