0%

Command

You can use commands to use in the MVVM pattern, Different types of commands are available.

RelayCommand

1
inherited from `ICommand`
1
2
3
4
5
6
7
8
private ICommand itemInvokedCommand;

public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<string>(OnItemInvoked));

public void OnItemInvoked(string arg)
{

}

DelegateCommand

Implementation of ICommand where the Execute and CanExecute callbacks are handled by delegates.

1
2
3
4
5
6
7
8
9
10
11
public ICommand AddItems { get; }

public TestViewModel()
{
AddItems = DelegateCommand.Create(OnAddItems);
}

private void AddItemsImpl()
{
Debug.WriteLine("Hello");
}

you can use IDelegateCommand Instead of ICommand