I’m working on project that based on WPF and MVVM.
I have some UserControl (summaryView) which has DataContext to ViewModel(SummaryVM).
I want put a button in summaryView and set the button DataContex to another viewModel(MainWindowViewModel) but it’s not working for me.
This is the NameSpace of the ViewModel
xmlns:vm="clr-namespace:ContentSync.ViewModel"
This is my button
<Button HorizontalAlignment="Left" Width="100" Height="30" Margin="0,20" DataContex=... Command="{Binding ModifyUserSettingsCommand}">Modify</Button>
The command ModifyUserSettingsCommand is located at MainWindowViewModel and the but I don’t know how to bind it to my button. I think I need to set it`s DataContext but I didn’t succeed in figuring out what is the right syntax
Thanks
Add to UserControl reousrces this:
And with that way you must assign DataContext to Button: