WPF and initial focus -


It seems that when a WPF application is launched, then there is no focus.

This is really strange. I used to use every other framework only what you expected: The tab focuses initial focus on the first control in the order but I have confirmed that this is not only a WP app, but not my app - if I create a new window, and If you put a text box in it and run the app, then the focus does not focus on the text box unless I click on it or click on the tab. Yuk.

My actual app is more complex than just a text box. There are several layers of user controls within user control. One of these UserControls has Focus = "True" and Keydown / Keyup handler, and as soon as My window opens, I want to focus it. I'm still a WPF newbie to some extent, though, and I do not feel very fortunate how to do it.

If I start my app and press the tab key, then the focus goes to me focus control, and this is the way I want to start working, but I can get my users window Do not want to hit the tab before using it.

I played with Focus Manager. Focus Element, but I'm not sure what set it is to set (top-level window? Parents who are in the focusable control? Focusable control themselves?) Or what to set it.

What do I need to do for my deep-nest control as soon as the window opens, the initial focus? Or better, to focus on the first focusable control in tab order?

I had a bright idea through dignified view and see how to use the focus property Goes, and I found my way to this solution. I need to add the following code to the manufacturer of my window:

  loaded = = (sender, e) => Movfocus (New Traversal Revest (Focus Navigation Direction. Next));  

This will automatically select the first control in the tab order, so this is a common solution that should be left in any window and just work.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -