diff --git a/Stylet/Xaml/ActionExtension.cs b/Stylet/Xaml/ActionExtension.cs
index 9b78cce..d4e11d1 100644
--- a/Stylet/Xaml/ActionExtension.cs
+++ b/Stylet/Xaml/ActionExtension.cs
@@ -11,6 +11,11 @@ namespace Stylet.Xaml
///
public enum ActionUnavailableBehaviour
{
+ ///
+ /// The default behaviour. What this is depends on whether this applies to an action or target, and an event or ICommand
+ ///
+ Default,
+
///
/// Enable the control anyway. Clicking/etc the control won't do anything
///
@@ -40,12 +45,12 @@ namespace Stylet.Xaml
///
/// Behaviour if the View.ActionTarget is nulil
///
- public ActionUnavailableBehaviour? NullTarget { get; set; }
+ public ActionUnavailableBehaviour NullTarget { get; set; }
///
/// Behaviour if the action itself isn't found on the View.ActionTarget
///
- public ActionUnavailableBehaviour? ActionNotFound { get; set; }
+ public ActionUnavailableBehaviour ActionNotFound { get; set; }
///
/// Create a new ActionExtension
@@ -73,13 +78,17 @@ namespace Stylet.Xaml
var propertyAsDependencyProperty = valueService.TargetProperty as DependencyProperty;
if (propertyAsDependencyProperty != null && propertyAsDependencyProperty.PropertyType == typeof(ICommand))
{
- return new CommandAction((DependencyObject)valueService.TargetObject, this.Method, this.NullTarget.GetValueOrDefault(ActionUnavailableBehaviour.Disable), this.ActionNotFound.GetValueOrDefault(ActionUnavailableBehaviour.Throw));
+ var nullTarget = this.NullTarget == ActionUnavailableBehaviour.Default ? ActionUnavailableBehaviour.Disable : this.NullTarget;
+ var actionNotFound = this.ActionNotFound == ActionUnavailableBehaviour.Default ? ActionUnavailableBehaviour.Throw : this.ActionNotFound;
+ return new CommandAction((DependencyObject)valueService.TargetObject, this.Method, nullTarget, actionNotFound);
}
var propertyAsEventInfo = valueService.TargetProperty as EventInfo;
if (propertyAsEventInfo != null)
{
- var ec = new EventAction((DependencyObject)valueService.TargetObject, propertyAsEventInfo, this.Method, this.NullTarget.GetValueOrDefault(ActionUnavailableBehaviour.Enable), this.ActionNotFound.GetValueOrDefault(ActionUnavailableBehaviour.Throw));
+ var nullTarget = this.NullTarget == ActionUnavailableBehaviour.Default ? ActionUnavailableBehaviour.Enable : this.NullTarget;
+ var actionNotFound = this.ActionNotFound == ActionUnavailableBehaviour.Default ? ActionUnavailableBehaviour.Throw : this.ActionNotFound;
+ var ec = new EventAction((DependencyObject)valueService.TargetObject, propertyAsEventInfo, this.Method, nullTarget, actionNotFound);
return ec.GetDelegate();
}