Wpf DataGrid MVVM模式实现双击

时间:2016-08-03 21:56:45   收藏:0   阅读:1409

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!