Files
DrunkDial/Components/xamarin.mobile-0.7.7/samples/Xamarin.Mobile.WP8.Samples/GeolocationSample/DelegatedCommand.cs
Tommy Parnell 09b555d296 init
2016-01-22 22:28:01 -05:00

43 lines
883 B
C#

using System;
using System.Windows.Input;
namespace GeolocationSample
{
public class DelegatedCommand
: ICommand
{
public DelegatedCommand (Action<object> execute, Func<object, bool> canExecute)
{
if (execute == null)
throw new ArgumentNullException ("execute");
if (canExecute == null)
throw new ArgumentNullException ("canExecute");
this.execute = execute;
this.canExecute = canExecute;
}
public event EventHandler CanExecuteChanged;
public void ChangeCanExecute()
{
var changed = CanExecuteChanged;
if (changed != null)
changed (this, EventArgs.Empty);
}
public bool CanExecute (object parameter)
{
return this.canExecute (parameter);
}
public void Execute (object parameter)
{
this.execute (parameter);
}
private readonly Action<object> execute;
private readonly Func<object, bool> canExecute;
}
}