(Translated by https://www.hiragana.jp/)
GitHub - MichalKuracina/ICommand: Interface example
Skip to content

MichalKuracina/ICommand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ICommand

Solution demonstrates how ICommand interface works in WPF.

using System;
using System.Windows.Input;

namespace wpf_icommand.ViewModels.Commands
{
    public class MessageCommand : ICommand
    {
        public event EventHandler CanExecuteChanged;
        private Action _execute;

        public MessageCommand(Action execute)
        {
            _execute = execute;
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            _execute.Invoke();
        }
    }
}

Link to documentation -> docs.microsoft.com