Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 742 Bytes

README.md

File metadata and controls

34 lines (27 loc) · 742 Bytes

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