gpt4 book ai didi

silverlight - Silverlight 4 控件是否有默认键盘行为引用?

转载 作者:行者123 更新时间:2023-12-03 08:30:40 24 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

4年前关闭。




Improve this question




在微软官方文档中,只有一段提到了控件对键盘的行为(至少我能找到):
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.


有没有更完整的引用资料?
例如,在 AutoCompleteBox 中,您可以按向上/向下导航到建议并选择一个按 Enter 等。
肯定有比专注于每一个控件并按下键盘上的每一个键来找出更好的方法:)

最佳答案

查看源代码\Reflector。

控件文本处理中有很多怪癖,我怀疑是否有人愿意记录这一点。例如,当用户在控件中有文本时按下 BackSpace 时,不会触发 TextBox 的 KeyDown 事件,但在没有文本时触发,等等。找到某些东西如何工作的最快方法是挖掘源代码。

我想出了一个很好的规则:如果出于某种原因您需要知道某些控制在某些情况下的行为方式,请不要浪费时间尝试编写(重现)这种情况,只需获取 Reflector 并查看源代码即可。

关于silverlight - Silverlight 4 控件是否有默认键盘行为引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4207693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com