blob: cc7adcd93fca932cb05a743802c995d56be9ba1b (
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 : ICommand
{
readonly Action action;
readonly Func<bool> canExecute;
public DelegateCommand(Action execute, Func<bool> canExecute)
{
this.action = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute();
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
action();
}
public void NotifyCanExecuteChanged()
{
if (CanExecuteChanged != null)
{
CanExecuteChanged(this, EventArgs.Empty);
}
}
}
}
|