In UWP, I want to handle and skip the tab key navigation for particular set of controls dynamically.
For e.g., I've two user controls (Both have lot of children which will be added dynamically) in my main page and want to skip tab key navigation for one usercontrol dynamically on specific scenario for a moment.
So I've tried to set "IsTabStop" as false to that UserControl. But which is not effective on its child controls. Still tab key focus moved inside the children of that UserControl.
Note: If I set "IsEnabled" as false, then its working. But I don't want to use because it affects Visual appearance.
Thanks in advance.
There is no
IsTabStopproperty inStackPanelclass. TheIsTabStopproperty is defined in Windows.UI.Xaml.Controls.Control class, and theStackPanelclass is not inherited fromControlclass, either directly or indirectly. You can not useIsTabStopproperty to set aStackPanelinstance.Therefore, if you want to skip tab key navigation for one stackpanel, you need to set the
IsTabStopproperty toFalsein each control in the stackpanel.Update:
By testing, the child elements in a
UserControlcan not inherit the value ofIsTabStopproperty. Therefore, you cannot skip tab key navigation for all the child elements in aUserControlby setting theIsTabStopproperty to False.You could use a method defind in your
UserControlclass to setIsTabStopto false for every item in yourUserControl.For example:
MyUserControl.cs
Use the name of a
UserControlinstance to call theSetIsTabStop(bool flag)method withFalse.Update:
Maybe you could try the following workaround.
Add the
KeyDownevent handler for theUserControlin yourPage.You need to let the first control except the
UserControland all its child controls get the focus, then the key navigation will skip the child controls in theUserControlexcept the first child control in theUserControl.