Browse Source
* test: Add test navigation with CanExecute is False * fix: Navigation when CanExecute is falserelease/11.0.6
committed by
Max Katz
4 changed files with 61 additions and 15 deletions
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Windows.Input; |
|||
|
|||
namespace Avalonia.Base.UnitTests.Utilities; |
|||
|
|||
internal class DelegateCommand : ICommand |
|||
{ |
|||
private readonly Action _action; |
|||
private readonly Func<object, bool> _canExecute; |
|||
public DelegateCommand(Action action, Func<object, bool> canExecute = default) |
|||
{ |
|||
_action = action; |
|||
_canExecute = canExecute ?? new(_ => true); |
|||
} |
|||
|
|||
public event EventHandler CanExecuteChanged { add { } remove { } } |
|||
public bool CanExecute(object parameter) => _canExecute(parameter); |
|||
public void Execute(object parameter) => _action(); |
|||
} |
|||
Loading…
Reference in new issue