Is there a reference of default keyboard behaviours for Silverlight 4 controls? [closed]
Asked Answered
W

3

34

In the official Microsoft documentation there's only one paragraph mentioning how controls behave to keyboard (at least what I could find):

http://msdn.microsoft.com/en-us/library/cc189015(v=VS.95).aspx#inputting_text

Text Input and Controls

Certain controls react to keyboard events with their own handling. For instance, a TextBox is a control that is designed to capture and then visually represent text that was entered by using the keyboard, and it uses KeyUp and KeyDown in its own logic to capture keystrokes, then also raises its own TextChanged event if the text actually changed. You can still generally add handlers for KeyUp and KeyDown to a TextBox, or any related control that is intended to process text input. However, as part of its intended design, a control might not respond to all key values that are directed to it through key events. Behavior is specific to each control. As an example, ButtonBase (base class for Button) processes KeyUp so that it can check for the SPACEBAR or ENTER key, which it considers equivalent to a mouse left button down for purposes of raising a Click event. This processing of the event is accomplished by ButtonBase overriding the virtual method OnKeyUp, and in its implementation it sets Handled = true. The result is that any parent of a button listening for a key event in the case of a SPACEBAR would not receive the already-handled event for its own handlers. Another example is TextBox. Some keys such as the ARROW keys are not considered text by TextBox and are instead considered specific to the control UI behavior, and the TextBox marks these event cases as handled.

Custom controls can implement their own similar override behavior for key events by overriding OnKeyDown / OnKeyUp. If your custom control processes specific accelerator keys, or has control or focus behavior that is similar to the scenario described for TextBox, you should place this logic in your own OnKeyDown / OnKeyUp overrides.

Is there a more complete reference anywhere?

For example in an AutoCompleteBox you can navigate to suggestions pressing up / down and choose one pressing enter, etc etc.

Surely there must be a better way than focusing every single control and pressing every single key on the keyboard to find out :)

Willowwillowy answered 17/11, 2010 at 18:18 Comment(1)
Maybe this would help.... dummies.com/how-to/content/…Perspex
S
1

Look in source code \ Reflector.

There are lots of quirks in controls text processing, I doubt that any one will care to document this. For instance KeyDown event of TextBox is not fired when user presses BackSpace when there is text inside control, but fires when the is no text, etc. The quickest way to find how something work is to dig into source.

I have figured a nice rule: if for some reason you need to know how some control will behave is some situation don't waste you time trying to code (reproduce) this situation, just get Reflector and look at source code.

Stigmatize answered 23/7, 2011 at 8:32 Comment(1)
I'm marking this as accepted answer as so far this is the most robust way, but I'm secretly hoping there is at least some crowd-sourced reference out there... :)Willowwillowy
I
1

Here is the link for the official ms short cuts, http://support.microsoft.com/kb/126449 tThey are being added to for Windows 8 http://www.itworld.com/software/203881/windows-8-metro-keyboard-shortcuts-and-tips hope this helps

Ibex answered 16/9, 2011 at 14:50 Comment(1)
This is almost it :) I guess Silverlight controls more or less have to adhere to Windows design guidelines so it's good thinking, but seems that this reference has more global keyboard shortcuts and mostly key combinations :(Willowwillowy
B
0

Are these the drones you're looking for? http://www.silverlight.net/archives/videos/keyboard-control

Buprestid answered 27/7, 2011 at 9:17 Comment(1)
This tutorial describes how to add keyboard shortcuts to custom controls, but what I'm after is a reference for the built in controls (and perhaps even the Silverlight Toolkit ones).Willowwillowy

© 2022 - 2024 — McMap. All rights reserved.