如何检测列表视图滚动条上的双击? [英] How to detect double click on list view scroll bar?

查看:84
本文介绍了如何检测列表视图滚动条上的双击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF上有两个列表视图.第一个列表视图加载了一个数据表.在第一个列表视图中双击一个项目时,selectedItem将移至第二个列表视图.

I have two list view on WPF. The first listview is loaded with a Datatable. When double clicking on one item from the first listview, the selectedItem is moved to the second listview.

由于从DataTable加载了很多元素,因此在第一个列表视图中出现滚动条时会出现问题.如果选择一个项目并双击滚动条向下箭头,则将启动MouseDoubleClick事件,并将所选项目移至第二个列表视图.

The problem arises when appears an scroll bar in the first list view due to a lot of elements loaded from the DataTable. If a select one item and double click on the scroll bar down arrow, MouseDoubleClick event is launched and the selected item is moved to the second listview.

我如何才能检测到滚动条上的双击来防止这种情况发生?

How I can detect the double click on the scroll bar to prevent this?

非常感谢!

推荐答案

我测试了上面的代码,该代码非常有帮助,但发现以下代码更稳定,因为有时您实际上是双重的,有时将源报告为GridViewRowPresenter.点击一个项目.

I tested the above code which was very helpful, but found the following to be more stable, as sometimes the source gets reported as GridViewRowPresenter when in fact you are double clicking an item.

var src = VisualTreeHelper.GetParent((DependencyObject)e.OriginalSource);
var srcType = src.GetType();
if (srcType == typeof(ListViewItem) || srcType == typeof(GridViewRowPresenter))
{
    // Your logic here
}

这篇关于如何检测列表视图滚动条上的双击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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