WPF, C# - change selected tab by doubleclick on a datagrid's row -


i have datagrid in tabcontrol item. when doubleclick row in datagrid, want tabcontrol change tab.

heres code:

<tabitem             x:name="tidashboard"             header="dashboard"             background="white">              <grid>                     <datagrid                             isreadonly="true"                             x:name="dganzeigewerk"                             autogeneratecolumns="false"                             margin="0,10,0,249"                              headersvisibility="column"                             rowheight="25" horizontalalignment="left" width="492">                          <datagrid.resources>                             <style targettype="{x:type datagridrow}">                                 <eventsetter event="control.mousedoubleclick" handler="dganzeigewerk_row_doubleclick"/>                             </style>                         </datagrid.resources>                          <datagrid.columns>                             <datagridtextcolumn width="auto" header="nummer" binding="{binding kostenstellennummer}"/>                             <datagridtextcolumn width="auto" header="kostenstelle" binding="{binding kostenstelle}"/>                             <datagridtextcolumn width="*" header="kosten" binding="{binding kosten}"/>                         </datagrid.columns>                      </datagrid>                     <combobox x:name="cbyearwerk" horizontalalignment="left" height="25" margin="497,10,0,0" verticalalignment="top" width="98" verticalcontentalignment="center" selectionchanged="cbyearwerk_selectionchanged"/>                     <separator height="15" margin="0,-10,0,0" verticalalignment="top"/>                  </grid>             </grid>         </tabitem> ... 

to change tabitem use code:

private void dganzeigewerk_row_doubleclick(object sender, mousebuttoneventargs e)     {          tabcontrol.selecteditem = tiuebersicht;     } 

but tab won't change. tried same code button , worked. tried tabcontrol.selectedindex = 2 or tiuebersicht.isselected = true without success.

any suggestions?

add e.handled = true; handler @ end.

private void dganzeigewerk_row_doubleclick(object sender, mousebuttoneventargs e)     {         tabcontrol.selecteditem = tiuebersicht;         e.handled = true;     } 

actually selection changing happening fast , focus returning 1 containing datagrid. can verified using selectionchanged event of tabcontrol.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -