Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF DataGrid double click via commands + INotifyPropertyChanged?

Tags:

c#

mvvm

wpf

I want a command in my ViewModel to be executed when DataGrid item is clicked. As a parameter I want to have corresponding row.

I've found one approach in internet but it using DependencyProperty

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/632ea875-a5b8-4d47-85b3-b30f28e0b827

I don't use DependencyProperty in my project, instead i'm using INotifyPropertyChanged. How to implement "double click in datagrid" commaind without using DependencyProperty?

like image 546
Oleg Vazhnev Avatar asked Dec 09 '22 04:12

Oleg Vazhnev


1 Answers

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
...
<DataGrid SelectedItem={Binding MySelectedItem, Mode=TwoWay}>
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseDoubleClick">
        <i:InvokeCommandAction Command="{Binding YourCommand}" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</DataGrid>
like image 119
vidalsasoon Avatar answered Dec 11 '22 17:12

vidalsasoon