0

Please help to create the Row Double Click event for datagrid using MVVM, currently i am using MouseDoubleClick event, using MouseDoubleClick event when we click anywhere on datagrid then that event is firing. Please help me to produce the event only when double click on rows.

Code that currently i am using i.e. MouseDoubleClick event:

  <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <i:InvokeCommandAction Command="{Binding RowClick}" CommandParameter="{Binding ElementName=grdManageCab, Path=SelectedItem}">
                        </i:InvokeCommandAction>
                    </i:EventTrigger>
                </i:Interaction.Triggers>  

1 Answers1

2

You are Subscribing the event on the DataGrid. And when you DoubleClick the entire Datagrid will fire the event. If you want that this event fire only on the Cells you must susbribe this evento on a DataGridCell

<DataGrid>
    <DataGridCell>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick">
                 <i:InvokeCommandAction Command="{Binding RowClick}" CommandParameter="{Binding ElementName=grdManageCab, Path=SelectedItem}">
                  </i:InvokeCommandAction>
             </i:EventTrigger>
         </i:Interaction.Triggers>
     </DataGridCell>
</DataGrid>

For more info please here.

Hope helps. Greetings!

soydachi
  • 851
  • 1
  • 9
  • 24
  • Hi thanks for giving answer, when i am adding this code then unhandled exception is coming at design time. Thanks, Greetings – Ashfaque Hussain Mar 11 '14 at 08:08
  • Hi, oh sorry, then try this link http://stackoverflow.com/a/17422019/2362643 is a very similar question. I am not expert with DataGrid, but I think that the event should subscripted on the Cell property. Hope helps! – soydachi Mar 11 '14 at 08:43