本文介绍了SilverLight Datagrid Row doubleclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

是否有使用MVVM方法处理Silverlight DataGrid中的行双击事件的简单方法.

预先感谢.

Is there any simple way to handle the row double click event in a silverlight datagrid using the MVVM approach.

Thanks in advance.

推荐答案


Private _LastClick As DateTime = DateTime.MinValue
    Private _DoubleClickTime As Double = 1500
    Private _LastDataGridRow As MyModel= Nothing


Private Sub DataGrid1_MouseLeftButtonUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles DataGrid1.MouseLeftButtonUp
        Dim viewModel As MyViewModel = CType(Me.DataContext, MyViewModel )
        Dim clickTime As DateTime = DateTime.Now
        Dim currentRowClicked As MyModel
        If viewModel.CanRetrieveQuote Then
          currentRowClicked = CType(CType(sender, DataGrid).SelectedItem, MyModel)
          Dim isDoubleClick As Boolean = (currentRowClicked.Equals(_LastDataGridRow)) And clickTime.Subtract(_LastClick) <= TimeSpan.FromMilliseconds(_DoubleClickTime)
            If isDoubleClick Then
                viewModel.RetrieveQuote()
            End If
            _LastClick = clickTime
            _LastDataGridRow = currentRowClicked
        End If

    End Sub



希望这对尝试解决此问题的人可能有所帮助.

谢谢!



Hope this might be helpful for anyone trying to resolve this issue.

Thanks!


DateTime lastClick = DateTime.Now;
private void dgv_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    if ((DateTime.Now - lastClick).Ticks < 2500000)
    {
        //this.View();
        MessageBox.Show("Double click!");
    }
    lastClick = DateTime.Now;
}


这篇关于SilverLight Datagrid Row doubleclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:19