标签:
xaml
<DataGrid x:Name="myGrd" ItemsSource="{Binding SearchItems}" SelectedItem="{Binding SelectedItem}" SelectionMode="Single" SelectionUnit="FullRow"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <cmd:EventToCommand Command="{Binding MouseDoubleClickCommand}" CommandParameter="{Binding ElementName=myGrd, Path=SelectedItem}" /> </i:EventTrigger> </i:Interaction.Triggers> ... </DataGrid>
ViewModel
public ICommand MouseDoubleClickCommand { get { if (mouseDoubleClickCommand == null) { mouseDoubleClickCommand = new RelayCommand<SearchItem>( item => { var selectedetitem = item; } ); } return mouseDoubleClickCommand; } }
WPF中DataGrid双击命令获取选中的ViewModel
标签:
原文地址:http://www.cnblogs.com/saybookcat/p/5190892.html