Facebook Like Box

Main Menu

How to set Tab Order of controls in WPF with large number of controls

Some days back I was working on a WPF project in which I had to develop many screens with lot of controls on it (about 200 controls on each screen like checkboxes, text editors, radiobuttons), once i completed the GUI work I noticed that on many of GUIs Taborder of controls were not working properly. I had to fix that, I googled a bit for this issue that what would be the easy way to set tab order of such big GUIs.

 Most of the articles were describing to set the tab order using Tab Index, consider the following example.


For the above case If you press Tab button while keeping focus on first radio button the control will first move on Yes buttons and then on No buttons for both rows, which is not a desired behavior, usually we want that first it should go to Yes and No of first row and then to second row. First solution would be

The above will surely solve the problem, but consider when you have hundreds of Radio buttons then it would be very difficult to add Tabindex for each Control even with Expression blend.

After some hit and try I identified that how WPF set the Taborder by default, my finding is that if you don't set the TabIndex then it would set the Taborder in sequential way you have written Controls in XAMLs, means the control comes first in XAML will get higher Tabindex than the later one. So another nice solution which I adopted for my GUIs is

And you are done with correct Tab Order. In this way you just need to move the existing tested XAML up and down for setting TabOrder.

Add comment

Security code