simsenVejle
Well-known member
- Joined
- Feb 14, 2021
- Messages
- 46
- Programming Experience
- Beginner
Hi,
I'm designing a wpf program with mvvm and now I'm confused which way I should do the "problem" with multiple datacontext to a usercontrol.
I have googled a lot and find out, that I can do it in two ways;
Make the vm extended with the foreign key and these properties in the view model
Or
Make a databinding to the second datacontext.
My overview:
I have a usercontrol where I bind to the DataContext CategoryViewModel in codebehind.
But in the Category model there is an foreign key to the Project model.
In the Usercontrol I want a combobox with all the projects and then the selected project should be the selected Categorys ProjectId
Now I do not know what is best practice databind to multiple datacontexts or to do it in the ViewModel?
Best regards
Simsen
I'm designing a wpf program with mvvm and now I'm confused which way I should do the "problem" with multiple datacontext to a usercontrol.
I have googled a lot and find out, that I can do it in two ways;
Make the vm extended with the foreign key and these properties in the view model
Or
Make a databinding to the second datacontext.
My overview:
I have a usercontrol where I bind to the DataContext CategoryViewModel in codebehind.
But in the Category model there is an foreign key to the Project model.
In the Usercontrol I want a combobox with all the projects and then the selected project should be the selected Categorys ProjectId
Now I do not know what is best practice databind to multiple datacontexts or to do it in the ViewModel?
Best regards
Simsen