问题描述
我有一个具有 textBox 元素的通用 Windows 平台项目.
我想在单击单选按钮时将焦点设置为它.
I have a Universal Windows Platform project that has a textBox element.
I'd like to set the focus to it when a Radio Button is clicked.
在单选按钮点击事件中,我可以说:
In the Radio Button click event, I can say:
txtBoxID.IsEnabled = true;
txtBoxID.Text = "";
但是我如何设置焦点?我看到一些答案说要使用:
But how do I set the focus? I saw some answers saying to use:
FocusManager.SetFocusedElement(
但是我的 FocusManager 类没有那个方法.
but my FocusManager class doesn't have that method.
已解决,谢谢.只需要知道要传递给 SetFocus 的参数.另一个人的问题被认为是相似的,是关于在他将焦点集中到他的控制上之后发生的事件.
edit: Solved, thanks. Just needed to know what argument to pass to SetFocus. The other fellow's question which was thought to be similar was regarding an event occurring after he set focus to his control.
推荐答案
您需要的所有代码是:
txtBoxID.Focus(FocusState.Programmatic);
方法定义在 控制.
这篇关于将焦点设置到 uwp 中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!