using System.Windows.Input; namespace YwxApp.AiChat.Commands { /// /// Scroll command : The argument object passed by this constructor of this class is ScrollViewer /// class ScrollViewerCommand : ICommand { private readonly Action _execute; private readonly Predicate _canExecute; public ScrollViewerCommand(Action execute, Predicate canExecute = null) { _execute = execute ?? throw new ArgumentNullException(nameof(execute)); _canExecute = canExecute; } public bool CanExecute(object parameter) { return _canExecute == null || _canExecute(parameter); } public void Execute(object parameter) { _execute(parameter); } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } } }