I've got a WPF browser-like application with a few pages. When I switch between pages, I'd like to set the keyboard focus.
When a page is loaded the first time, this works by calling Control.Focus()
in the constructor.
But when I switch between pages this does not work anymore - the focus is just on the first field, and ignores my attempts to change it to anything else :(
The pages have the attribute KeepAlive=true
- it would be OK if that would keep the focus alive, too, but just setting the focus to the first field is annoying.
I tried to set the focus in the loaded event, but it did not work, too. It seems the default focus is set after reloading the page.
Is there any way to set the focus on entering a page the second time? When, how and where should I set the focus when switching between WPF pages in a browserlike application?