Summary
In this chapter you saw how the event handling approach has been changed in WPF with the introduction of RoutedCommands and WeakEventManagers. You can implement a WPF command in three different ways. The first approach is to recycle one of the existing RoutedCommands provided by WPF in the ApplicationCommands class and provide the implementation of the Execute and the CanExecute methods in the code-behind file of a Window or UserControl.
The second way is to create a custom RoutedCommand and attach it to the CommandBinding collection of the corresponding View. The third approach, more complex but also more flexible, is to create a custom command class that implements the ICommand interface and that is also able to trigger its execution ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access