How to add PreviewKeyUp event to all cells ?
I wanna catch tab key press for 开发者_C百科each cell in edit mode.
Thanks guys
Just register PreviewKeyUp
in one of the parent elements such as the DataGrid itself or the window, the Datagrid is within. Analye then the events OriginalSource to know from where the event has been coming.
To access the rows data you can do something like:
FrameworkElement fe=e.OriginalSource;
if(null != fe){
YourRowDataObject rowData=fe.DataContext as YourRowDataObject;
// work here with your data
}
精彩评论