Example how to Create CommandBindingin in WPF:
Command Binding in WPF working like Bubbles and will stop
only if: e.Handled = true, if e.Handled = false Command will continue finding all VisualTree untill root element.
XAML:
<UserControl.CommandBindings>
<CommandBinding Command="Save"
CanExecute="SaveCanExecute"
Executed="SaveExecuted">
</CommandBinding>
<CommandBinding Command="{x:Static local:WorkOrderDetailsTreeViewModel._SetEditorFocus}"
Executed="_SetEditorFocusExecuted"/>
</UserControl.CommandBindings>
C#:
private void SaveCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
e.Handled = true;
}
private void SaveExecuted(object sender, ExecutedRoutedEventArgs e)
{
//TODO;
}
Found best multi event command binder in codeplex
השבמחקMulti Event Command Binder
Benefits:
1:Ability to bind multiple event to multiple commands.
2:In CommandArgs in command handler you can even get original event args this was not possible with existing command binders.
3:In CommandArgs in command handler you can even get original source of the event this was not possible with existing command binders.
4:In this you can control individual CanExecute methods.
Blogs
Multi Event Command BlogSpot
Multi Event Command WordPress