开发者

Programmatically move Cursor to a TextBlock

开发者 https://www.devze.com 2023-01-06 06:07 出处:网络
in my application I\'m opening a Window as a dialog. Inside this win开发者_开发知识库dow, there\'s a TextBox called \"myText\". When the dialog is shown, I want the cursor to be automatically inside t

in my application I'm opening a Window as a dialog. Inside this win开发者_开发知识库dow, there's a TextBox called "myText". When the dialog is shown, I want the cursor to be automatically inside the "myText" TextBox, so the user can immediately enter something without having to click in the TextBox. I however have problems realising this, can somebody please help me with this? Thank you very much for any hint!


Set the FocusManager.FocusedElement property on your Window:

FocusManager.FocusedElement="{Binding ElementName=myText}"


Or myText.Focus() in your Loaded event

0

精彩评论

暂无评论...
验证码 换一张
取 消