SilverLight Datagrid Row doubleclick事件 [英] SilverLight Datagrid Row doubleclick event

查看:104
本文介绍了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.

推荐答案



我在google上找到了:

http://www.dansoltesz.com/post/2010/02/19/Silverlight-datagrid-double-click-behavior.aspx [
Hi,

I found that on google:

http://www.dansoltesz.com/post/2010/02/19/Silverlight-datagrid-double-click-behavior.aspx[^]

Valery.


感谢瓦莱里.

这是我使用鼠标上移事件背后的代码解决的方法:

Thanks Valery.

Here''s how I resolved it using code behind mouse up event:

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事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆