This is a problem I've often faced and it's a tricky one. From my understanding, the reason that it doesn't work as you'd expect is because tab order (even specified via TabIndex
) is contextual. TabIndex of higher level items will be prioritized over inner elements. So if you have two TabItem
s inside of a TabControl
, and each one has UIElement
s inside of them, even if the TabIndex
is specified, tabbing will first traverse the TabItem
s before it moves down to the contents of those controls. I "think", IIRC" this has to do with how the page is composed, but don't quote me on that. MS has weird reasons for some of these subtle nuances.
Onto the solution. What I've done in the past (so long as you're NOT working on WinRT, which makes this problem even worse) you can use UIElement.Focus. I store a list of UIElement
s in the order I wish them to be when tabbed in the code. Then, by binding the KeyDown
event to a common handler for all of these controls, I do something like this:
int currentIndex = TabbableControls.IndexOf(sender);
UIElement next = TabbableControls[(currentIndex + 1) % TabbableControls.Length];
next.Focus();
Hope this helps!