0

I'm adding a validation module to my application which will guide the user to the inputs that need attention. I would like to go through these controls in the same order that they were added to the Visual Tree. The Tab Index for each control is set to Int Max, which means just go in order of the Visual Tree.

My validation module just gets a bunch of controls to validate. It needs to order them from top to bottom so the user can go sequentially through the form. I would like to preserve the original tabbing behavior. I just need to know the visual tree order of the controls in my list so I can sort them properly.

NielW
  • 3,626
  • 1
  • 30
  • 38
  • Have you tried calling all the controls and then get their current tabindex? If so, what else have you tried? – Sinnich Jun 21 '16 at 12:18
  • Unless explicitly set, the current tab index is set to Int Max which just means, go in order of the visual tree. Yes, I have tried this. – NielW Jun 21 '16 at 15:05

1 Answers1

0

After a couple days of research, I realized this is not provided out of the box. In the end, I just called FindVisualChildren to get all FrameworkElements, and if the control implemented my IValidatable interface, I assigned it the next available index from a counter. I had to add a dependency property called Order to make it work (I didn't want to muck with the existing TabIndex). Then, when I got my list of controls needing validation, I just sorted them by Order.

This is definitely not a scalable solution, but luckily I only need to run it once.

If anyone has a better solution, PLEASE post it. I feel dirty.

Community
  • 1
  • 1
NielW
  • 3,626
  • 1
  • 30
  • 38