从它失去焦点的元素设置焦点 [英] Set focus of an element from its lost focus

查看:211
本文介绍了从它失去焦点的元素设置焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,注重文本框是需要的,所以焦点再次被设置为从失去焦点的文本框。这导致堆放超过了失去焦点事件流中。

For some reason focus a text box is need, so the focus is again set to the text box from its lost focus. This leads to stack over flow in the lost focus event.

说,
一个文本框和一个按钮,现在的工作重点是在文本框,然后点击按钮。在这种情况下,所需要的焦点是在文本框中,所以集中的文本框的方法是从其失去焦点时调用。这导致堆放超过流量的异常。

Say, A Textbox and a button, now the focus is in Textbox and clicking on the button. In this case, need the focus to be in the textbox, so focus method of text box is invoked from its lost focus. This leads to stack over flow exception.

为什么出现这种情况,以及如何做焦点保留在文本框本身。

Why this happens and also how do the focus is retained in text box itself.

通过处理文本框的PreviewKeyboardLostFocus,我都保留了键盘焦点,但如何留住这个鼠标焦点?

By handling PreviewKeyboardLostFocus of textbox, i have retained the Keyboard focus but how to retain the mouse focus in this?

推荐答案

检查您是否已经处理的SetFocus()事件,你可能已经处理的东西有导致StackOverflowException。

Check if you had handled SetFocus() Event, You might have handled something there leading to StackOverflowException.

干杯!

这篇关于从它失去焦点的元素设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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