怎样获取DataGrid被双击的行 How to find DataGrid Double Clicked Row

项目中要求datagrid能支持双击导航。但客户有可能点击到其它地方,比如column header, Border,....怎么来确定用户双击的是datagrid的某一行用下面的方法可以解决

      public DataGridRow GetDataGridRow(MouseButtonEventArgs e)
        { 
            FrameworkElement source = e.OriginalSource as FrameworkElement;
            return DataGridRow.GetRowContainingElement(source);
       }

上面函数返回空的则表示点击了其它地方,反之也成立

原文地址:https://www.cnblogs.com/mjgb/p/2087472.html