I am starting to get my feet wet in the Xbox UWP Creator Program. I'm coming from Windows Phone 7 & 8.
I have not been able to figure out how to set the Button Focus to my desired buttons via code behind or StoryBoard animation.
I have a single page app that is using 13 buttons in total, but not all buttons are on screen at the same time. The buttons are animated onto the screen in pairs (Yes - No) using Storyboards.
The First Button has correct focus when displayed.
The next two buttons are displayed after first button is pressed and deactivated with Visibility.Collapsed. The Right most button is displayed with Focus when these buttons are set with Visibility.Visible. I need the left button to have focus.
The second pair of Yes-No buttons are displayed when first pair is hidden with Visibility.Collapsed. When these two buttons are displayed the focus rectangle is not visible. It appears when Left Stick or D-Pad is moved. I need the left most button to have focus.
All the remaining pairs display without focus set, as above.
I have been reading docs here:
But frankly, I'm a bit stumped on how to set, or reset the focus on UI elements using either in code-behind or in a StoryBoard.
I need to use the separate pairs of buttons as opposed to just using two buttons (1 yes, 1 no and using a case statement) for visual reasons. So popping these buttons on and off is messing up with the built-in visual state focus manager.
Any pushes in the correct direction would be most welcomed.
Thank you, -David
E.g., set focus to the button called
MyButton
from code-behind:You may also find the following properties of UI elements useful:
TabIndex
to change the order in which elements get focus.AllowFocusOnInteraction
to keep a UI element from getting focus when it's interacted with.