| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Input;namespace Aitex.UI.RecipeEditor{    public class DelegatedCommand : ICommand    {        public DelegatedCommand(Predicate<object> CanExecute, Action<object> Execute)        {            _canExecute = CanExecute;            _execute = Execute;        }        Predicate<object> _canExecute;        Action<object> _execute;        /// <summary>        ///         /// </summary>        /// <param name="parameter"></param>        /// <returns></returns>        public bool CanExecute(object parameter)        {            if (_canExecute != null)                return _canExecute.Invoke(parameter);            return true;        }        public event EventHandler CanExecuteChanged;        public void Execute(object parameter)        {            if (_execute != null)                _execute.Invoke(parameter);        }        public void RaiseCanExecuteChanged()        {            if (CanExecuteChanged != null)                CanExecuteChanged(this, EventArgs.Empty);        }    }}
 |