Welcome to Manicprogrammer Sign in | Join | Help

Rediscovering the Obvious

An occasional journey through one man's perspectives as he fumbles along in the footsteps of many great men.
InputBinding == flexibility

I was frustrated yesterday because I had 8 different buttons on a screen that were perfect for RoutedUICommand bindings with the CommandParameter set to a different value on each. However, they each also needed a different KeyGesture attached, and as far as I knew yesterday, you only could tie gestures to commands through the Command.InputGestures collection.

Not true!  The following code uses an InputBinding to tie a gesture on a specific control to a RoutedUICommand with a specified CommandParameter. Life is good, off to code!

                InputBinding inBind = new InputBinding(SomeCommand, new KeyGesture(Key.NumPad1));
                inBind.CommandParameter = commandType;
                control.InputBindings.Add(inBind);
 

 

Published Friday, August 03, 2007 9:11 AM by willeke

Filed under: ,

Comments

No Comments

Anonymous comments are disabled