У меня есть следующий класс для RelayCommand:
Код: Выделить всё
using System.Windows.Input;
namespace RCadastral.MVVM
{
public class RelayCommand : ICommand
{
private Action execute;
private Func canExecute;
public event EventHandler? CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public RelayCommand(Action execute, Func canExecute = null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object? parameter)
{
return canExecute == null || canExecute(parameter);
}
public void Execute(object? parameter)
{
execute(parameter);
}
}
}
Код: Выделить всё
Код: Выделить всё
public RelayCommand CloseCommand => new RelayCommand(execute => Close());
private void Close(Window window)
{
// Sime logic...
window.Close();
}
Я очень запутался, ничего не помогло. Помогите пожалуйста.
Подробнее здесь: https://stackoverflow.com/questions/791 ... ied-member