-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRelayCommand.cs
More file actions
29 lines (23 loc) · 929 Bytes
/
Copy pathRelayCommand.cs
File metadata and controls
29 lines (23 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace MusicBeePlugin
{
public class RelayCommand : ICommand
{
private readonly Action<object> executeAction;
private readonly Predicate<object> canExecutePredicate;
public event EventHandler CanExecuteChanged;
public RelayCommand(Action<object> executeAction, Predicate<object> canExecutePredicate)
{
this.executeAction = executeAction;
this.canExecutePredicate = canExecutePredicate;
}
public void Execute(object parameter) => this.executeAction?.Invoke(parameter);
public bool CanExecute(object parameter) => this.canExecutePredicate?.Invoke(parameter) ?? true;
public void NotifyCanExecuteChanged() => this.CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}