20241106_MiLu_upperpc/DeerProject/Common/CommandBase.cs

34 lines
766 B
C#
Raw Normal View History

2025-02-20 05:54:12 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace DeerProject.Common
{
public class CommandBase : ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return DoCanExcute?.Invoke(parameter) == true;
}
public void Execute(object parameter)
{
DoExcute?.Invoke(parameter);
}
public Action<object> DoExcute { set; get; }
public Func<object, bool> DoCanExcute { set; get; }
public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
}