51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
|
|
namespace 常用工具集.Base
|
|
{
|
|
public class DelegateCommand : ICommand
|
|
{
|
|
public Action<object> ExecuteCommand = null;
|
|
public Func<object, bool> CanExecuteCommand = null;
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
public DelegateCommand()
|
|
{
|
|
}
|
|
|
|
public DelegateCommand(Action<object> Command)
|
|
{
|
|
ExecuteCommand = Command;
|
|
}
|
|
|
|
public bool CanExecute(object paramter)
|
|
{
|
|
if (CanExecuteCommand != null)
|
|
{
|
|
return CanExecuteCommand(paramter);
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public void Execute(object paramter)
|
|
{
|
|
if (ExecuteCommand != null)
|
|
ExecuteCommand(paramter);
|
|
}
|
|
|
|
public void RaiseCanExecuteChanged()
|
|
{
|
|
if (CanExecuteChanged != null)
|
|
CanExecuteChanged(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|