I am creating a WPF application and am having a little difficulty implementing an user interface idea I have.
I have a MasterViewModel
bound to the MainWindow
which exposes an observable collection of ViewModels
. I have written some commands that essentially switch the current view model in the observable collection and this subsequently displays the corresponding view. However, when the application first loads, I add a HomeViewModel
to the collection which shows the Home (Navigation) View. The problem I am having is the Commands I am binding against are exposed on the MasterViewModel
so they aren't 'cascading' into the items control. Can anyone offer a solution or a better one? Many Thanks.
This is the error I am receiving:
System.Windows.Data Error: 40 :
BindingExpression path error:
'MainWindowViewModel' property not found on 'object' ''HomeViewModel' (HashCode=5313339)'. BindingExpression:Path=MainWindowViewModel.LoadClientsCommand;
DataItem='HomeViewModel' (HashCode=5313339);
target element is 'Button' (Name='');
target property is 'Command' (type 'ICommand')