mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-27 11:43:24 +08:00
添加项目文件。
This commit is contained in:
35
gong-wpf-dragdrop/src/Showcase/ViewModels/SimpleCommand.cs
Normal file
35
gong-wpf-dragdrop/src/Showcase/ViewModels/SimpleCommand.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Showcase.WPF.DragDrop.ViewModels
|
||||
{
|
||||
public class SimpleCommand : ICommand
|
||||
{
|
||||
public SimpleCommand(Action<object> execute = null, Predicate<object> canExecute = null)
|
||||
{
|
||||
this.CanExecuteDelegate = canExecute;
|
||||
this.ExecuteDelegate = execute;
|
||||
}
|
||||
|
||||
public Predicate<object> CanExecuteDelegate { get; set; }
|
||||
|
||||
public Action<object> ExecuteDelegate { get; set; }
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
var canExecute = this.CanExecuteDelegate;
|
||||
return canExecute == null || canExecute(parameter);
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
this.ExecuteDelegate?.Invoke(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user