While WPF provides a number of predefined routed commands that you can use, it can also be useful to define your own command to use in your application.
We start by defining an instance of a RoutedCommand, in this case defined as a static member of our main Window class. We also define code for the CanExecute and Executed events that will perform the logic that we bind the command to.
We can now set up a command binding from XAML and set the Command property for controls that should execute our command.
We now have a command that executes when we click a button or a menu item in a context menu.