How to add DataContext to User Control's XAML?
I have a user control MyControl, it needs to be bound to its view model: MyControlViewModel. I have no problem to add the DataContext programmically in the constructor. But I was told this is not allowed. It has to be done in the XAML. However, I have gotten the error in XAML
MyControlViewModel is in the project MyProject.ViewModel
<local:MyControlViewModel/> // ERROR: The name MyControlViewModel does not exist in the namespace "clr-namespace:MyProject.ViewModel"
// Style stuff...
Anyone can help me?
Thanks a lot.