Reputation: 2097
I'm sure this is a noob question, but can't figure out what's probably obvious.
In our app, a ContentDialog opens from a button press. When the ContentDialog closes, we'd like the focus to return to the Page button that invoked it. Now it goes to the first control on the Page (a TextBox). This is jarring, especially when using Narrator.
A Dialog_OnClosing event is already plumbed, but I can't figure out what to put here to put the focus on the button.
To clarify: answers so far will not work as stated, because the closing event is in the dialog. How do I set focus on a button in the invoking Page, NOT a button on the dialog?
Upvotes: 0
Views: 541
Reputation: 26989
It inherits the Focus
method and you can use it like this:
someButton.Focus(FocusState.Programmatic);
More about Focus
here.
Upvotes: 1
Reputation: 2290
buttonID.Focus(FocusState.Programmatic);
should do the trick!
Upvotes: 1