-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75e1a5b
commit e6f486c
Showing
11 changed files
with
267 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Windows.Input; | ||
|
||
namespace Diol.Wpf.Core.Services | ||
{ | ||
public class RelayCommand : ICommand | ||
{ | ||
private readonly Action<object> _execute; | ||
private readonly Func<object, bool> _canExecute; | ||
|
||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null) | ||
{ | ||
_execute = execute ?? throw new ArgumentNullException(nameof(execute)); | ||
_canExecute = canExecute; | ||
} | ||
|
||
public bool CanExecute(object parameter) => _canExecute?.Invoke(parameter) ?? true; | ||
|
||
public void Execute(object parameter) => _execute(parameter); | ||
|
||
public event EventHandler CanExecuteChanged | ||
{ | ||
add => CommandManager.RequerySuggested += value; | ||
remove => CommandManager.RequerySuggested -= value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.