Reputation: 289
Because of this question I know how to set the focus of a Control (Windows.UI.Xaml.Controls.Control); however, I do not know how to get access to the ContentDialog's SeocndaryButton in order to set it's focus. This is not the same as setting it as the DefaultButton. When I do that I still cannot just hit enter to activate the secondary button.
Does anyone know how to do this?
Upvotes: 0
Views: 338
Reputation: 1469
It's possible for you to think about using custom dialog instead of using the default button. You can have a look at this case. In general, when you customize your own buttons, you can add the functions you want to these buttons to have your own logic. Does this make sense to you?(I've tested with custom buttons' focus and it works)
Upvotes: 1
Reputation: 289
For now I could only come up with a workaround. I wanted the enter key to do the same as if I hit the secondaryButton. When I overrode the enter key it never dismissed the dialog, but!!! If I added a hide to it, it seems to work as intended. I would like to know how to give it focus, but this will work for now.
protected override void OnKeyUp(KeyRoutedEventArgs e)
{
base.OnKeyUp(e);
if (e.Key == Windows.System.VirtualKey.Enter)
{
ContentDialog_SecondaryButtonClick(null, null);
this.Hide();
}
}
Upvotes: 0