A lot of the MVVM guidance around commands suggest using a generic ICommand implementation, such as the RelayCommand or GenericCommand implementations. These are great for UI pieces that are bound directly to an underlying ViewModel and I use them frequently.

There are still cases where a RoutedUICommand is exactly what one needs. Take, for instance, toolbar buttons or menu items that need to act on pages that are loaded in a WPF frame. In this case, a RoutedUICommand is appropriate since it is decoupled from the page, which may or may not be loaded at the time.

One challenge with MVVM based scenarios is connecting a routed command to an implementation that lives in the ViewModel. As usual, Josh Smith has an solution… Josh wrote a ViewModel Commanding sample back in 2008 and posted it to CodeProject.

It took me a little bit of review to understand the way it works, but the end result is a very clean and simple implementation that stays close to the original design intent behind WPF’s routed commands.

Thanks Josh!