views:

33

answers:

2

Hello,

in my application I'm opening a Window as a dialog. Inside this window, 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!

A: 

Set the FocusManager.FocusedElement property on your Window:

FocusManager.FocusedElement="{Binding ElementName=myText}"
Quartermeister
Didn't try that because Nirs solution worked, anyways thanks for your reply!
stefan.at.wpf
+1  A: 

Or myText.Focus() in your Loaded event

Nir
Thank you, works fine :-)
stefan.at.wpf