专注于文本框 [英] Keep focus on textbox

查看:95
本文介绍了专注于文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试通过执行以下操作将初始焦点设置在UserControl中的某个Textbox上:

Hi all,

I am trying to set the initial focus on a certain Textbox within my UserControl, by doing the following:

<br />
<pre><br />
FocusManager.FocusedElement="{Binding ElementName=txtBarCode}"<br />
</pre><br />


A .它设置了焦点,但是光标没有闪烁?仅当我单击文本框"时,它才会开始闪烁吗?
B .其次,如何保持对文本框的关注.

提前非常感谢!
问候


A. It sets the focus, but the cursor does not flicker? Only when I click on the Textbox, does it start flickering?
B. Secondly, how can I keep the focus on the Textbox.

Many thanks in advance!
Kind regards

推荐答案

将逻辑焦点设置为输入控件
To set logical focus to an input control
FocusManager.SetFocusedElement(this, textboxJack);  





使用此代码:



or

Use this code:

private void Button_Click(object sender, RoutedEventArgs e)
{
    textBox.Focus();
    textBox.SelectionStart = textName.Text.Length;
}


这篇关于专注于文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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