文本框专注于加载 - 奇怪的行为 [英] Textbox focus on load - strange behaviour
问题描述
我有简单的WP7 silverlight页面,只有一个TextBox。在LayoutRoot中加载事件处理程序 我把textBox1.Focus()。仿真器启用了硬件键盘(PgDn)。加载页面时,文本框得到焦点,插入符号闪烁。但是我不能在
中输入任何文字。直到我用鼠标点击文本框。然后我可以输入文字。
这个功能或模拟器中的错误?在具有硬件键盘的设备中是否存在相同的行为?
我不认为这是一个错误。也许usercontrol不处于焦点状态。在填写文本框之前尝试聚焦用户控件。
还有一个选项,
使用以下代码聚焦文本框
Deployment.Current.Dispatcher.BeginInvoke(委托{TextBoxObject.Focus();});
I have simple WP7 silverlight page with only one TextBox. In LayoutRoot Load event handler I put textBox1.Focus(). Emulator has hardware keyboard enabled (PgDn). When page is loaded, textbox got focus and caret is blinking. But I cannot enter any text in
it. Until I click into textbox with mouse. Then I can enter text.
Is this feature or bug in emulator? Is same behaviour present in devices with hardware keyboard?
I dont think this is a bug. Maybe the usercontrol is not in the focussed state. Try focussing the user control before you foucs textbox.
One more option,
Use the following code to focus textbox
Deployment.Current.Dispatcher.BeginInvoke(delegate { TextBoxObject.Focus(); });
这篇关于文本框专注于加载 - 奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!