Wpf DataGrid MVVM模式实现双击

Instead of double-clicking on the cell you may double-click on the grid

1 <DataGrid.InputBindings>
2 <MouseBinding Gesture="LeftDoubleClick" Command="{Binding Edit}" CommandParameter="{Binding ElementName=UsersDataGrid, Path=SelectedItem}" />
3 </DataGrid.InputBindings>

 

In ViewModel

 1 public ICommand Edit { get; private set; }
 2 
 3 Edit = new RelayCommand(EditUser, x => _isAdmin);
 4 
 5 private static void EditUser(object usr)
 6 {
 7 if (!(usr is User))
 8 return;
 9 
10 new UserEditorViewModel(usr as User);
11 }

 

转自:http://stackoverflow.com/questions/18595654/wpf-datagrid-double-click-cell-mvvm-design

posted @ 2016-08-03 20:25  一叶扁舟卷画帘  阅读(3071)  评论(0编辑  收藏  举报