I've got a few sdk AutoCompleteBox's that I just want to set IsTabStop="False" on. If you do so it's ignored and still takes focus/tab action.
So I went digging into the template and found the embedded TextBox in there with it explicitly hardcoded to IsTabStop=True so I figured I could just pull that out, TemplateBind to an unused property like Tag to set it at the instance level and just provide a setter in the template for default True, right?
No joy though, it still ignores it. So I tried just setting it False explicitly in the template. Which sure enough removes it from the Tab order. HOWEVER, it also disables the control so it won't accept focus or edit at all.
I've ran into similar situations in the past but none of my tricks are working. Anyone ran into this before? What am I missing to just make the damn thing fall out of tab order? I'm also rather confused why setting the IsTabStop on the embedded TextBox would disable the control from all hittestvisibility....
Not sure where the reasoning is for setting to just have the property ignored nor have found explanation in any docs yet.
So, maybe another pair of eyes might help before I go too far down the rabbit hole for something seemingly so simple, any thoughts? Thanks!
The
TextBoxinside theAutoCompleteBoxcan only own keyboard focus when all criteria for focus ownership are met:ControlLoadedevent fired / visual parent in not null anymore [I use an extension methodIsLoaded])IsTabStopmust be trueTherefore you have to let the internal
TextBoxhave its tabstoppy ways. But we have other options. I thought about using aContentControland settingTabNavigation="Once". As far as I understood it is supposed to have the Control and all its content behave like one solid piece in the tab navigation chain, so theoretically when tabbing you will step at the ContentControl, but never down into its content.But I tried it and it is not working as expected. Don't know where my thinking is wrong here.
I played around with it and found the following solution is working:
Surround them with a
FocusDitcher(we derive from ContentControl und make the control ditch the focusOnGotFocus, but not if triggered by the user clicking into the inner TextBox). We could alternatively write aBehaviorfor that. For focus ditching, the control has to sabotage one of the prerequisites for focus ownership, like going to disabled mode and back to enabled (not working with IsTabStop, tried it, failed).and template