Implementing ICommand
The ICommand
interface is part of the commanding system in Silverlight and is usually recognizable alongside the Model-View-ViewModel (MVVM) pattern. The MVVM pattern aids the developer to separate the UI layer (View) from the code layer (Model) using a connector in between (ViewModel). The commanding system allows us to wire business logic functionality directly to buttons on the UI layer using XAML. Now, you may be thinking that we can already do that using event handlers and writing code in the code behind file of our XAML, and you would be right. But think about a scenario where you have to use the button logic elsewhere in the application. You will need to write another even handler for the new button, copy the logic over from the old one, and wire the Click
event of the new button to the new handler. Instead, by using the commanding system, you can bind a command to a button. The command logic is placed in the ViewModel layer, which means that any button on the...