返回首页

有任何简单的方法来处理一个Silverlight的DataGrid行的双击事件使用MVVM方法。

感谢在前进。

回答

评论会员:ArchnaG 时间:2012/02/07
。瓦列里・

下面是我如何解决它背后使用鼠标向上事件的代码:


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

 


希望对于任何试图解决这个问题,这可能是有用的。

感谢:瓦列里・possoz
评论会员:游客 时间:2012/02/07
嗨,我发现,在谷歌:imgsrc=瓦列里:会员4775529
{C}