最简单的silverlight的DataGrid行双击事件添加
本人看了很多的行双击事件,觉得都太负载,如:用Timer,Thread等,于是自己决定写一个简单的,如下
this.DataGrid1.LoadingRow += Grid_LoadingRow;
private void Grid_LoadingRow( object sender, DataGridRowEventArgs e)
{
e.Row.MouseLeftButtonUp += Row_MouseLeftButtonUp;
}
private void Row_MouseLeftButtonDown( object sender, MouseButtonEventArgs e)
{
TimeSpan t = DateTime.Now.TimeOfDay;
if ( this.DataGrid1.Tag != null)
{
TimeSpan oldT = (TimeSpan) this.DataGrid1.Tag;
if ((t - oldT) < TimeSpan.FromMilliseconds(300))
{
MessageBox.Show( "xxx");
}
}
this.DataGrid1.Tag = t;
}
private void Grid_LoadingRow( object sender, DataGridRowEventArgs e)
{
e.Row.MouseLeftButtonUp += Row_MouseLeftButtonUp;
}
private void Row_MouseLeftButtonDown( object sender, MouseButtonEventArgs e)
{
TimeSpan t = DateTime.Now.TimeOfDay;
if ( this.DataGrid1.Tag != null)
{
TimeSpan oldT = (TimeSpan) this.DataGrid1.Tag;
if ((t - oldT) < TimeSpan.FromMilliseconds(300))
{
MessageBox.Show( "xxx");
}
}
this.DataGrid1.Tag = t;
}
本文来Stym--闫生的博客,原文地址:http://www.cnblogs.com/yansheng9988/archive/2011/04/28/2032002.html
但是经本人实际测试,发现一些问题,就是它的单击一次就