wpf - MouseDoubleClick Event on DatagridTemplateColumn -


how add mousedoubleclick event on datagridtemplatecolumn?

my column:

<datagridtemplatecolumn header="pk">      <datagridtemplatecolumn.celltemplate>         <datatemplate>             <image name="pk" horizontalalignment="center" stretch="none" />             <datatemplate.triggers>                 <datatrigger binding="{binding path=primary_key}" value="j">     <setter targetname="pk" property="source" value="/userinterface;component/resources/images/key.png"/>                 </datatrigger>             </datatemplate.triggers>         </datatemplate>     </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

i mousedoubleclick event on datagrid itself, offcourse fires on every doubleclick on cell :

private sub dgcolumns_mousedoubleclick(byval sender system.object, byval e system.windows.input.mousebuttoneventargs)     dim dg datagrid = ctype(sender, datagrid)     if dg.selecteditem isnot nothing andalso dg.selecteditem.gettype gettype(attribuut)         if ctype(dg.selecteditem, attribuut).primary_key = "j"             ctype(dg.selecteditem, attribuut).primary_key = "n"         else             ctype(dg.selecteditem, attribuut).primary_key = "j"         end if     end if end sub 

this makes column image change, when leave cell, how instantaneously?

i suggest wrap image in contentcontrol. contentcontrol subclass of control. mousedoubleclick defined in control class.

<contentcontrol mousedoubleclick="cc_mousedoubleclick">     <image name="pk" source="my.png" horizontalalignment="center" stretch="none" /> </contentcontrol> 

Comments