Umbau angefangen auf ICommand
This commit is contained in:
32
KanSan.ViewModel/Commands/RelayCommand.cs
Normal file
32
KanSan.ViewModel/Commands/RelayCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel.Commands
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action<object> execute;
|
||||
private Func<object, bool> canExecute;
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
|
||||
{
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return this.canExecute == null || this.canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
this.execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user