c# - Custom Command in WPF to allow dependency property value change in "realtime" -


I have a scenario where in my custom control I have a custom dependency property which is MinValue Type int .

I want to allow the user to convert that input to the keyboard input by using Ctrl ++ (increase) and Ctrl + - (decrease). I can do this with commands, but where is the command to implement those commands

I think that implementing the command in my custom control Because, users should only be able to use the keyboard shortcut already No matter what control is in the window. This control knows what to do with keyboard shortcuts, but since I have a custom handlebank, and everyone should have a shortcut, I'm not sure how this will work any sign? Thank you as always!

There are other ways to do this, and possibly there are good reasons to do this like this.

TestControl: User control code UserControl {// declared routed command generic routing Command increment commm; Public static routing commodity decree; Static TestControl () {// Create Routed Orders and Add Key Gestures Invert Commands = New Routing Commands (); DecrementCommand = new routing commands (); Inverted Command.InputJesures.Add (new keystream (key.ad, Modifier Keys control)); DecrementCommand.InputGestures.Add (new key gearcher (key wine, modifier. Kontrol)); } Public Trial Control () {// Increase / Declining events Subscribe to TestControl.Decremented + = Down; TestControl.Incremented + = Up; InitializeComponent (); } // declaration * steady * increase / decrease incidents Public Static Event Increase EventHandler; Public Stable Event Decreased EventHandler; // arises the phenomenon of rise in the public static zero incremental object (object o, executed by rotated adventure arguments) {if (invent! = Empty) {increased (O, args); }} // wakes up curves occurrence public static zero DecrementMin (object o, digitized aventarge arguments) {if (deducted! = Zero) {deductible (o, args); }} // Handler for Private Growth Private Zero Down (Object O, Event Argus Args) {Min -; } // handler private zero-ups for static depreciation (object o, eventargs args) {min ++; } // The benefits of the property are public and minimum {get {return (int) GetValue (MinProperty); } Set {set value (minports, values); }} Dependency property for public static reading MinProperty = DependencyProperty.Register ("Minimum", Type (Int), Typef (Test Control), New UIPpropy Metadata (0)); }

On the window this behavior is desired, these commands require adding commandbinding to the window code:

  public main window () {InitializeComponent (); // Raise static events of control in response to root commands. Commandsbinding.ed (new commandbanding (test control, increment command, event handler with new executed route (Test Control Incrimment)); This.CommandBinding.Add (new commandbing (TestControl.DecrementCommand, new executedAttendantHandler (TestControl.DecrementMin)); }  

Does it help?

(Oh, BTW - Just like this code reacts on the keypad +/- keys, and not at the top) ([] ()) key - I work with the first major gestures have not done it. Certainly this can not be corrected.)


Comments