set focus to a textBox in uwp [duplicate]

[亡魂溺海] 提交于 2020-01-13 16:39:08

问题


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(

but my FocusManager class doesn't have that method.

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.


回答1:


All the code you need is:

txtBoxID.Focus(FocusState.Programmatic);

Method is defined in Control.



来源:https://stackoverflow.com/questions/42243817/set-focus-to-a-textbox-in-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!