dex3703
dex3703

Reputation: 2097

Set focus on specific button when ContextDialog closed

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

Answers (2)

CodingYoshi
CodingYoshi

Reputation: 26989

It inherits the Focus method and you can use it like this:

someButton.Focus(FocusState.Programmatic);

More about Focus here.

Upvotes: 1

Brett Merrifield
Brett Merrifield

Reputation: 2290

buttonID.Focus(FocusState.Programmatic); should do the trick!

Upvotes: 1

Related Questions