c# - How to get listview datatemplate item doubleclicked WPF MVVM -


how can bind datatemplate show in listview , being doubleclicked?

i want smthing this:

<checkbox grid.column="1" grid.row="5" command="{binding additemcommand}"></checkbox> 

i have done, don't know how bind command datatemplate in listview or grid in datatemplate.

datatempalte this:

<datatemplate x:key="serverviewitemtemplate" datatype="viewmodel:serverviewmodel">         <border borderbrush="black" borderthickness="1" margin="10">              <grid>                 <grid.columndefinitions>                     <columndefinition width="70" />                     <columndefinition width="*" />                 </grid.columndefinitions>                  <grid.rowdefinitions>                     <rowdefinition height="20" />                     <rowdefinition height="20" />                     <rowdefinition height="20" />                     <rowdefinition height="20" />                     <rowdefinition height="20" />                     <rowdefinition height="20" />                 </grid.rowdefinitions>                  <textblock grid.column="0" grid.row="0" text="serverid:" fontweight="bold"/>                 <textblock grid.column="1" grid.row="0" text="{binding serverid}" fontweight="bold"/>                 <textblock grid.column="0" grid.row="1" text="login:"/>                 <textblock grid.column="1" grid.row="1" text="{binding login}" />                 <textblock grid.column="0" grid.row="2" text="password:"/>                 <textblock grid.column="1" grid.row="2" text="{binding password}" />                 <textblock grid.column="0" grid.row="3" text="type:"/>                 <textblock grid.column="1" grid.row="3" text="{binding type}" />                 <textblock grid.column="0" grid.row="4" text="ipaddress:"/>                 <textblock grid.column="1" grid.row="4" text="{binding ipaddress}" />                 <textblock grid.column="0" grid.row="5" text="include:"/>                 <checkbox grid.column="1" grid.row="5" command="{binding additemcommand}"></checkbox>             </grid>         </border>     </datatemplate> 

so if double-clicked should call icommand, same in checkbox additemcommand.

i'd suggest behavior handle double click event. depending on want when double click, may need add icommand dependency property behavior can bind command on viewmodel.

here's similar post: is there way in xaml select text in textbox when double clicked?

in example, user selecting text in textbox when double clicked.

more:

your xaml this:

<datatemplate x:key="serverviewitemtemplate" datatype="viewmodel:serverviewmodel">     <border borderbrush="black" borderthickness="1" margin="10">          <grid>             <e.interaction.behaviors>                 <local:doubleclickbehavior command="{binding path=additemcommand}"/>             </e.interaction.behaviors>              <grid.columndefinitions>                 <columndefinition width="70" />                 <columndefinition width="*" />             </grid.columndefinitions> ... ... 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -