wpf - Firing a Command within EventTrigger of a style? -


as know can't bind event directly command without behaviour:

<datagrid>     <i:interaction.triggers>         <i:eventtrigger eventname="previewmousedoubleclick">             <i:invokecommandaction command="{binding tradeentrycommand"} />         </i:eventtrigger>     </i:interaction.triggers> </datagrid> 

this works fine, have refactor double clicking datagrid double clicking cell. (i don't care cell clicked)

i hoping define behviour inside cell style this:

<style x:key="defaultcellstylebase" targettype="{x:type datagridcell}">     <setter property="template">         <setter.value>             <controltemplate targettype="{x:type datagridcell}">                 <controltemplate.triggers>                     <eventtrigger routedevent="previewmousedoubleclick">                         ?????????                     </eventtrigger>                 </controltemplate.triggers>             </controltemplate>         </setter.value>     </setter>     <!-- ... --> </style> 

but how bring in behaviour above fire command?

highly appreciated,

since retemplating datagridcell, add triggers root element in control template. like:

<controltemplate targettype="{x:type datagridcell}">     <grid x:name="root" background="transparent">         <i:interaction.triggers>             <i:eventtrigger eventname="previewmousedoubleclick">                 <i:invokecommandaction command="{binding tradeentrycommand}" />             </i:eventtrigger>                                     </i:interaction.triggers>     </grid> </controltemplate> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -