I am relatively new to WPF MVVM. I am currently working on a small project to understand the details around the concepts of WPF MVVM and am facing a small issue that I cannot get my head around.
I have a main window with a <ContentControl Content="{Binding Path=CurrentViewModel}" />
with the CurrentViewModel property being set on the main window ViewModel class. The main window has three button controls for listing, editing and removing an entity. The ContentControl loads a UserControl (ListEntities) which lists all the entities from some data store. The UserControl xaml has its own ViewModel class which is being set to the ContentControl content property and the view gets loaded using DataTemplates.
This is all working fine. My requirement is that when a user will select a row in the ListEntities UserControl GridView, the Edit and Remove buttons has to be enabled(using the CanExecute method of the ICommand infrastructure). The issue is that I can set a SelectedEntity property on the UserControl ViewModel class based on SelectedItem property binding, but how do I get the selected item to be available to the main window view model class so as to enable the edit/remove buttons(how from the Parent View would I get to know that an item in the Child View has been selected using the MVVM pattern). So in a more generic way, I am trying to understand the most standard procedure to enable communication between the independent ViewModels of the Parent window and child User Control based on some event in either the Parent or the Child view.