c# - WPF - Setting tab order on large number of controls -
so have large amount of controls (textboxes) can see below, there around 30 rows of this. these loaded using arrays, , each column represents array. when hit tab in textbox, instead of tabbing horizontally, tabs vertically instead.
is there way set tab order tab horizontally, aside changing way controls loaded?
another quirk when leaving 1 textbox, instead of focusing next, kind of highlights textbox, , have tab second time inside next textbox.
edit:
main view (lots of code has been omitted, i'm pretty sure nothing has been left out needs here)
<listbox itemssource="{binding items}" scrollviewer.horizontalscrollbarvisibility="disabled"> <listbox.itemspanel> <itemspaneltemplate> <wrappanel isitemshost="true" /> </itemspaneltemplate> </listbox.itemspanel> </listbox> itemsview
<usercontrol> <usercontrol.resources> <datatemplate datatype="{x:type vm:item}"> <views:itemview/> </datatemplate> </usercontrol.resources> <stackpanel> <contentcontrol content="{binding item <!-- 30 different items here, omitted readability -->}" /> </stackpanel> </usercontrol> itemview
<usercontrol ... istabstop="false"> <textbox text="{binding value}" /> </usercontrol> the itemview nested in itemsview, nested in mainview. since textboxes generated based on array values, can't set tabindex property unless there way don't know (i pretty new @ wpf).
the tabindex property provides way control tab order independently of order controls loaded.
usage example:
<grid> <textbox tabindex="2" /><!-- receive focus second --> <textbox tabindex="1" /><!-- receive focus first--> </grid> i guess unwanted focusing seeing due parent usercontrol textboxes placed in.
if case, prevent setting istabstop="false" on parent control.
for example:
<usercontrol .... istabstop="false"> <grid> <!-- other graphics --> <textbox tabindex="1" /> </grid> </usercontrol> using view model populate data
public class cellviewmodel { public double value { get; set; } public int tabindex { get; set; } } public ienumerable<ienumerable<cellviewmodel>> getmatrix( list<list<double>> matrixvalues) { var columncount = matrixvalues.count; return matrixvalues .select((x, i) => getcolumn(x, columncount, i)); } public ienumerable<cellviewmodel> getcolumn( list<double> columnvalues, int columncount, int columnindex) { return columnvalues .select((x, i) => new cellviewmodel { value = x, tabindex = columnindex + columncount * }); } your itemssource listbox (which you've changed itemscontrol) should new matrix property, populate using getmatrix().
in itemview, want this:
<usercontrol ... istabstop="false"> <textbox text="{binding value}" tabindex="{binding tabindex}" /> </usercontrol> 
Comments
Post a Comment