WPF. How to set focus on an element by it's tab index? -


is possible element or set focus on (textbox, instance) it's tab index, if element part of datatemplate , tab index of element uniquely defined?

you can visualtreehelper search element created through templates.
therefore can check tabindex of existing element , find desired element (it tab-index unique:). can name elments in datatemplate , filter name.

the following function lets find elements of given type of visual tree.

void findchildframeworkelementsoftype<t>(dependencyobject parent,ilist<t> list) t: frameworkelement{                  dependencyobject child;      for(int i=0;i< visualtreehelper.getchildrencount(parent);i++){                      child = visualtreehelper.getchild(parent, i);          if (child t) {              list.add((t)child);          }          findchildframeworkelementsoftype<t>(child,list);      }  } 

call follows:

list<textbox>  textboxlist=new list<textbox>(); findchildframeworkelementsoftype<textbox>(rootobject,textboxlist); 

where rootobject root object such window or base control. list of textboxes , list can checked tab-index or whatever property want check.
take care tree must built before calling function. als there circumstances in above pattern not work, e.g. ui-virtualization in lists.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -