views:

264

answers:

0

I've built a WPF application. All of the UI elements except the Window are created in response to data binding. Thus, I set the DataContext of the Window, and voila -- a very large hierarchy of UI elements materializes on the screen. The UI contains lists of panels with lists, labels, more panels, textboxes, checkboxes, you name it. So far, so good.

The user has entered erroneous data into some of the text boxes, and again I use the data binding mechanism to display red borders around the erroneous text boxes and display the error message next to the text box. Again, so far, so good.

Since there are many screens of data here, a "navigate to next error" button would be very handy. Clicking the button would move the keyboard focus to the next element containing erroneous data. How do I implement that functionality? Obviously I'm not supposed to go walking willy-nilly around the element hierarchy because WPF makes that rather difficult to do. Is there some other way? I tried futzing with the WPF keyboard navigation code, which seems like the right answer, but it is not working on my window. I plan to spend time figuring out why, but I wanted to make sure there isn't some other road I should go down. I also saw some accessibility classes (*Peer), but they seemed overkill.

Thanks, - Mike