/
hlebusheck
/
notes
Обзор
Документация
Войти
/
hlebusheck
/
notes
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Notes.Wpf/Controls/Commands/RelayCommand.cs
33 строки
846 B
Hlebusheck
Add export and import
14 ноя 2022, 23:35
14 ноя 2022, 23:35
fd08b87
Код
Авторство
О чём код?
using System; using System.Windows.Input; namespace Notes.Controls.Commands { public class RelayCommand : ICommand { private Action<object> execute; private Func<object, bool> canExecute; public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public RelayCommand(Action<object> execute, Func<object, bool> 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); } } }