不调用KeyDown事件和OnKeyDown Override方法 [英] KeyDown event and OnKeyDown Override method is not called

查看:81
本文介绍了不调用KeyDown事件和OnKeyDown Override方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ContentControl,它的内容为网格……依此类推.如下图所示.

I have a ContentControl that has a grid as its content... and so on.. as shown in the below tree.

-ContentControl(视图)
    -网格
        -ContentPresenter
        -ScrollViewer
            -Panel(继承为Page)

-ContentControl(View)
    -Grid
         -ContentPresenter
         -ScrollViewer
              -Panel (inherited as Page)

所有方法将使Panel(Page)成为焦点.我在ContentControl(View)中具有KeyDown事件或OnKeyDownEvent Override方法,该事件为除箭头键之外的所有键触发.箭头键有什么特殊行为吗?谁能帮我 克服这个问题.

All ways Panel(Page) will be in focus. I have KeyDown event or the OnKeyDownEvent Override Method in ContentControl(View), this event is triggered for all the keys except for arrow keys. Is there any special behaviour for Arrow keys? can any onehelp me to overcome this.

注意:我只需要KeyDown事件或OnKeyDownEvent重写方法,并且没有其他任何内容.
        我没有在任何地方使用e.handled = true

Note: I need only  KeyDown event or the OnKeyDownEvent Override Method and not anything else.
         I have not use e.handled = true anywhere

 

推荐答案

我真的想接收所有按键事件,那么您需要参加预览..."事件.
KeyDown ist的问题在于,任何子控件都可以处理它(例如,文本框),并阻止您接收它.

I you really want to receive all key down events, then you need to go for the Preview... event.
The problem with the KeyDown ist, that any child control can handle it (e.g. Textbox), and that prevents you from receiving it.


这篇关于不调用KeyDown事件和OnKeyDown Override方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆