/
hlebusheck
/
notes
Обзор
Документация
Войти
/
hlebusheck
/
notes
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
Notes.Wpf/Controls/Commands/RelayCommand.cs
33 строки
870 B
Hlebusheck
NET 8
16 апр 2024, 19:11
16 апр 2024, 19:11
8638cf1
Код
Авторство
О чём код?
using System; using System.Windows.Input; namespace Notes.Controls.Commands { public class RelayCommand : ICommand { private readonly Action<object?> _execute; private readonly 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) { _execute = execute; _canExecute = canExecute; } public bool CanExecute(object? parameter) { return _canExecute == null || _canExecute(parameter); } public void Execute(object? parameter) { _execute(parameter); } } }