Can anyone tell me how to programmatically navigate through all UI element tab stops in a WPF application? I want to start with the first tab stop sniff the corresponding element, visit the next tab stop, sniff the corresponding element, and so on until I reach the last tab stop.
Thanks, - Mike
You can do this with the MoveFocus call. You can get the currently focused item through the FocusManager. The following code will iterate all objects in the window and add them to a list. Note that this will physically modify the window by switching the focus. Most likely the code will not work if the window is not active.
You do that using MoveFocus as shown in this MSDN article which explains everything about focus: Focus Overview.
Here is some sample code to get to the next focused element (got it from that article, slightly modified).