Saturday, 15 August 2015

c# - How to set the taborder for the Datatemplate textboxes in a listbox item? -



c# - How to set the taborder for the Datatemplate textboxes in a listbox item? -

i have listbox in wpf application generating listbox items using datatemplate in datatemplate have textboxes want taborder textboxes, how accomplish tried many ways of no use.

below xaml code :-

<datatemplate x:key="datatemplate1" > <grid height="100" width="1255" background="#ffda4f4f" keyboardnavigation.directionalnavigation="continue" margin="0,-8,0,0"> <grid.rowdefinitions> <rowdefinition height="62*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid x:name="maingrid" keyboardnavigation.tabnavigation="continue"> <canvas background="#f5f5f5" height="30" horizontalalignment="left" margin="213,31,0,0" x:name="canvas45" verticalalignment="top" width="92"> <textbox canvas.left="5" tabindex="13" keyboardnavigation.directionalnavigation="continue" text="{binding name}" canvas.top="5" height="20" tag="{binding}" lostfocus="txbbox1lostfocus" x:name="txbbox1" width="82" previewtextinput="txbbbox1_previewtextinput" background="red" /> </canvas> <canvas height="30" horizontalalignment="right" margin="0,31,186,0" x:name="canvas46" verticalalignment="top" width="92"> <textbox canvas.top="5" tabindex="14" height="20" x:name="txbbox2" lostfocus="txbbox2lostfocus" text="{binding txbbox2}" tag="{binding}" previewtextinput="txbbox2_previewtextinput" width="82" canvas.left="5" background="red" /> </canvas> </grid> </grid> </datatemplate>

and listbox i'm binding datatemplate.

<listbox x:name="listbox1" background="transparent" itemssource="{binding}" horizontalalignment="left" height="auto" margin="53,430,0,0" verticalalignment="top" width="1241" itemtemplate="{dynamicresource datatemplate1}" borderbrush="{x:null}" style="{dynamicresource jlistbox1}" itemcontainerstyle="{staticresource listbox1_itemcontainerstyle}" grid.columnspan="2" selectionchanged="listbox1_selectionchanged" />

please give me suggestion how it, in advance.

instead of setting tabindex each textbox within datatemplate, seek set tabnavigation cycle mode, move cursor next focusable field automatically.

please follow link more details http://social.technet.microsoft.com/wiki/contents/articles/25152.wpf-how-to-tab-between-items-in-a-listbox.aspx

c# wpf xaml listbox datatemplate

No comments:

Post a Comment