UIElement.OnAccessKey(AccessKeyEventArgs) Method


在调用对于此元素有意义的访问键时提供类处理。Provides class handling for when an access key that is meaningful for this element is invoked.

 virtual void OnAccessKey(System::Windows::Input::AccessKeyEventArgs ^ e);
protected virtual void OnAccessKey (System.Windows.Input.AccessKeyEventArgs e);
abstract member OnAccessKey : System.Windows.Input.AccessKeyEventArgs -> unit
override this.OnAccessKey : System.Windows.Input.AccessKeyEventArgs -> unit
Protected Overridable Sub OnAccessKey (e As AccessKeyEventArgs)



访问键事件的事件数据。The event data to the access key event. 事件数据报告哪个键被调用,并指示控制发送这些事件的 AccessKeyManager 对象是否也将此访问键调用发送到其他元素。The event data reports which key was invoked, and indicate whether the AccessKeyManager object that controls the sending of these events also sent this access key invocation to other elements.


UIElement 类或其他位置没有实际的 AccessKey 事件,您可以引发或附加的处理程序。There is no actual AccessKey event in the UIElement class, or elsewhere, which you can raise or attach handlers for. 相反,事件是通过一个专用的管理器类(AccessKeyManager)发出的,它会对所有输入进行后处理,以搜索适用于整个输入模型的访问密钥。Instead, the event is originated via a dedicated manager class, AccessKeyManager, which post-processes all input to search for access keys that are applicable to the entire input model.

Notes to Inheritors

此方法的默认实现 UIElement 将键盘焦点设置到此元素(通过调用 Focus())。The default implementation of this method in UIElement sets keyboard focus to this element (by calling Focus()). 如果实现可获得焦点,则实现应保持此行为,因为它是辅助功能方案的预期行为。Implementations should perpetuate this behavior if they are focusable, because it is an expected behavior for accessibility scenarios. 请注意,基实现对传递的事件数据不执行任何操作,并且不会引发进一步的事件;它只是设置焦点。Note that the base implementation does nothing with the passed event data and raises no further event; it just sets the focus.

Applies to