I am learning WPF and implementing MVC pattern.
In my controller class I am registering events like this. But the problem I cant find RoutedEvent for DataGrid Row committed.
EventManager.RegisterClassHandler(typeof(Control), DataGrid.SelectedEvent,
(SelectionChangedEventHandler) SelectionChanged);
//Get the full list of products by default
GetAllProducts();
}
#region Event Handler
//event handler for the selection changed
private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//Notify that the selected item has changed
if (e.AddedItems != null && e.AddedItems.Count > 0)
Mediator.NotifyColleagues(Messages.SelectProduct, e.AddedItems[0]);
}
It contains only RoutedCommands like CommitEditCommand. You can bind to it instead of subscribing for events and continue to process your workflow.
Though I’d like to remark that implementing MVC doesn’t stack well with WPF due to it’s more MVVM or MVP like structure. Massive use of bindings just proves the point.