WPF 文本框中的 GotFocus 和 LostFocus 事件

发布于 2024-10-09 12:52:21 字数 141 浏览 0 评论 0原文

我在 WPF 窗口中有一个文本框控件。我有单独的 GotFocus 和 LostFocus 事件处理程序。但是当文本框第一次获得焦点时,LostFocus会在GotFous之后调用(文本框第一次获得焦点后就会失去焦点)。但是当文本框第二次获得焦点时,这种情况不会发生。

I have a textBox control in a WPF window. I have separate handlers for GotFocus and LostFocus events. But when the textbox attains focus for the first time LostFocus is invoked after GotFous (The textbox loses focus as soon as it attains focus for the first time) . But this doesn't happen when the textBox attains focus for the second time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

横笛休吹塞上声 2024-10-16 12:52:21

听起来好像在 GotFocus 事件处理程序(或调用堆栈的更深处)期间发生了某些事情,将焦点放弃给另一个控件。

您可能想尝试在 LostFocus 事件处理程序中设置断点,然后查看调用堆栈以查看是否有某些内容直接或间接在其他地方设置了焦点。

Sounds like maybe something is happening during the GotFocus event handler (or deeper in the call stack) that is relinquishing focus to another control.

You might want to try setting a breakpoint in your LostFocus event handler and then look at the call stack to see if something is setting the focus elsewhere either directly or indirectly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文