WPF DataGrid 鼠标双击选中的DataGridRow及Row数据


设置DataGrid的MouseDoubleClick事件

代码

//DataGrid鼠标双击事件
Private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
{ 
  if(this.dataGrid.SelectedIndex == -1) 
  { 
    return; 
  } 
  DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContaineFormIndex(this.dataGrid.SelectedIndex); 
} 

这段代码有个缺点,就是只要鼠标双击DataGrid这个控件的任何位置都会触发这个事件而不是点击DataGridRow触发

望高手改正


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM