I have a problem with commands in an MVVM application (I am only learning MVVM so go easy).
MyClassViewModel is set to the datacontext for MainForm1, MyList is bound to UserControl1 datacontext and each item in the list is represented by UserControl2. I am trying to fire MyCommand in UserControl2 using the following:
<CheckBox IsChecked="{Binding MyBool}" Command="{Binding Path=MyCommand}" CommandParameter="{Binding}">
I get the following error in the output:
System.Windows.Data Error: 39 : BindingExpression path error: 'MyCommand' property not found on 'object' ''MyObject''
From this error I know that WPF is looking for the command in the object bound to the UserControl2 what I really need is for it to look for the command in the MainForm1 datacontext (MyClassViewModel).
Is it possible to bubble up commands like this and if so how is it done?
Is bubbling up the command a good solution?