Created
February 7, 2013 13:01
-
-
Save codler/4730765 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Input; | |
namespace HumanResourcesLib | |
{ | |
class DelegateCommand : ICommand | |
{ | |
public Action Do { get; set; } | |
public Func<bool> CanDo { get; set; } | |
public void ChangeCanDo() | |
{ | |
if (CanExecuteChanged != null) | |
CanExecuteChanged(this, new EventArgs()); | |
} | |
public bool CanExecute(object parameter) | |
{ | |
if (CanDo != null) | |
{ | |
return CanDo(); | |
} | |
return false; | |
} | |
public event EventHandler CanExecuteChanged; | |
public void Execute(object parameter) | |
{ | |
if (Do != null) | |
Do(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment