Skip to content

Instantly share code, notes, and snippets.

@codler
Created February 7, 2013 13:01
Show Gist options
  • Save codler/4730765 to your computer and use it in GitHub Desktop.
Save codler/4730765 to your computer and use it in GitHub Desktop.
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