怎样获取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);
       }

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

posted @ 2011-06-22 18:28  mjg  阅读(1174)  评论(3编辑  收藏  举报