在调试的焦点问题在WPF任何提示? [英] Any tips on debugging focus issues in WPF?

查看:143
本文介绍了在调试的焦点问题在WPF任何提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体而言,我有打开一个非模式子窗口的按钮。一些在主窗口中偷焦点从子窗口,因为它打开。

Specifically, I have a button that opens a non-modal child window. Something in the main window steals the focus away from the child window as it opens.

完全一般的方法是注释掉code部位,直到问题消失。我正在寻找更快的方法。

The fully general approach is to comment out parts of code until the problem goes away. I'm looking for faster methods.

推荐答案

我使用史努比现在这样做的权利。

I'm using Snoop to do this right now.

对于初学者来说,史努比显示当前的焦点元素和当前FocusScope在状态栏中。

For starters, Snoop shows the current focused element and the current FocusScope in the status bar.

您可以得到它向你展示所有的GotFocus和LostFocus事件:

You can get it to show you all the GotFocus and LostFocus events:

  1. 运行你的应用程序。
  2. 运行探听。
  3. 选择在下拉菜单中您的应用程序。
  4. 点击望远镜(探听)按钮。
  5. 在右侧窗格中,单击事件选项卡。
  6. 单击打倒下拉。
  7. 向下滚动到键盘部分,检查GotKeyboardFocus,LostKeyboardFocus,以及可选的previewXXX事件。
  8. 现在,做你需要做的操纵对焦和观赏探听窗口。

同样,你可以跟踪的FocusManager事件以同样的方式。

Similarly you can track the FocusManager events the same way.

这篇关于在调试的焦点问题在WPF任何提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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