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" />

Last edited Sep 20, 2012 at 2:18 AM by mglukhankov, version 1

Comments

No comments yet.