Browse Source

Added CommandParameter property for KeyBinding

Wiesław Šoltés 9 years ago
parent
commit
9ec94dc29d
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/Perspex.Input/KeyBinding.cs

+ 11 - 2
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);
             }
         }
     }