Here is an example of a view model class with a command:
public class SimpleViewModel
{
public SimpleViewModel()
{
SampleCommand = new RelayCommand(OnSample);
}
public ICommand SampleCommand { get; private set; }
private void OnSample()
{
// TODO Do something here.
}
}
Lets bind it to a button in XAML:
<Button Command="{Binding SampleCommand}"
Content="Button Text" />