Browse Source

Added CommandParameter property for KeyBinding

pull/471/head
Wiesław Šoltés 10 years ago
parent
commit
9ec94dc29d
  1. 13
      src/Perspex.Input/KeyBinding.cs

13
src/Perspex.Input/KeyBinding.cs

@ -18,6 +18,15 @@ namespace Perspex.Input
set { SetValue(CommandProperty, value); }
}
public static readonly StyledProperty<object> CommandParameterProperty =
PerspexProperty.Register<KeyBinding, object>("CommandParameter");
public object CommandParameter
{
get { return GetValue(CommandParameterProperty); }
set { SetValue(CommandParameterProperty, value); }
}
public static readonly StyledProperty<KeyGesture> GestureProperty =
PerspexProperty.Register<KeyBinding, KeyGesture>("Gesture");
@ -32,8 +41,8 @@ namespace Perspex.Input
if (Gesture?.Matches(args) == true)
{
args.Handled = true;
if (Command?.CanExecute(null) == true)
Command.Execute(null);
if (Command?.CanExecute(CommandParameter) == true)
Command.Execute(CommandParameter);
}
}
}

Loading…
Cancel
Save