您好,欢迎来到个人技术集锦。
搜索
当前位置:首页GameEngine游戏引擎前端界面wpf页面实现

GameEngine游戏引擎前端界面wpf页面实现

个人技术集锦 2025-06-08
导读1.RelayCommon.cs using System.Windows.Input; namespace PrimalEditor.Common {     public class RelayCommand : ICommand     {         private readonly Action _execute;         private readonly Predicate _canExecute;         public event Event

1.RelayCommon.cs

using System.Windows.Input;

namespace PrimalEditor.Common
{


    public class RelayCommand<T> : ICommand
    {

        private readonly Action<T> _execute;
        private readonly Predicate<T> _canExecute;

        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }

        }

        public bool CanExecute(object parameter)
        {

            return _canExecute?.Invoke((T)parameter) ?? true;


        }
        public void Execute(object parameter)
        {

            _execute((T)parameter);

        }

        public RelayCommand(Action<T> execute, Predicate<T> canExecute = null)
        {


            _execute = execute ?? throw new ArgumentNullException(nameof(execute));
            _canExecute = canExecute;

        }


    }

}
 

Copyright © 2019- zgxue.com 版权所有 京ICP备2021021884号-5

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务