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

问题描述

具体来说,我有一个按钮,打开一个非模态的子窗口。主窗口中的东西在打开时将焦点从儿童窗口中偷走。



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

解决方案

我正在使用这样做。



对于初学者,Snoop会在状态栏中显示当前关注的元素和当前的FocusScope。



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


  1. 运行你的应用程序。

  2. 运行

  3. 在下拉菜单中选择您的应用。

  4. 点击双筒望远镜(Snoop)按钮。

  5. 在右窗格中,单击事件选项卡。

  6. 单击以关闭下拉列表。

  7. 向下滚动到键盘部分并检查GotKeyboardFocus ,LostKeyboardFocus,以及可选的PreviewXXX事件。

  8. 现在做你需要做的操纵焦点并观看Snoop窗口。

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


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.

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.

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

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

  1. Run your app.
  2. Run Snoop.
  3. Choose your app in the dropdown.
  4. Click the binoculars ("Snoop") button.
  5. On the right pane, click the Events tab.
  6. Click to bring down the dropdown.
  7. Scroll down to the Keyboard section and check GotKeyboardFocus, LostKeyboardFocus, and optionally the PreviewXXX events.
  8. Now do what you need to do to manipulate focus and watch the Snoop window.

Similarly you can track the FocusManager events the same way.

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

08-11 11:54