Programmatically move Cursor to a TextBlock
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
精彩评论