blob: b9ee13ae902b78a77fd0c8831f82165f23f68062 (
plain) (
blame)
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
30
31
32
33
34
35
36
37
|
using System;
using System.Windows.Input;
namespace Juick.Classes
{
public class DelegateCommand<T> : ICommand
{
readonly Action<T> _action;
readonly Func<bool> _canExecute;
public DelegateCommand(Action<T> execute, Func<bool> canExecute)
{
_action = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute();
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
_action((T)parameter);
}
public void NotifyCanExecuteChanged()
{
if (CanExecuteChanged != null)
{
CanExecuteChanged(this, EventArgs.Empty);
}
}
}
}
|