Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Command<TExecuteParameter> (wraps Command<TCanExecuteParameter, TExecuteParameter> with object for TCanExecuteParameter)
  • Command (wraps Command<TExecuteParameter> with object for TExecuteParameter)

Examples

Code:

Code Block
private readonly IMessageService _messageService;
 
public void MyViewModel(IMessageService messageService)
{
    Argument.IsNotNull(() => messageService);
 
    _messageService = messageService;
    // Add commands
    MyAction = new Command(MyAction_Execute);
}

/// <summary>
/// Gets the MyAction command.
/// </summary>
public Command MyAction { get; private set; }

/// <summary>
/// Method to invoke when the MyAction command is executed.
/// </summary>
/// <param name="parameter">The parameter of the command.</param>
private void MyAction_Execute(object parameter)
{
    // Show message box
    var messageService = GetService<IMessageService>();
    _messageService.ShowInfo("My action in MVVM");
}

...