如何处理该事件上的空白处单击时? [英] How to handle the event when click on empty space?

查看:127
本文介绍了如何处理该事件上的空白处单击时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要赶在列表视图是从左点击空白处事件 - 即点击ListView控件内没有项目

I want to catch the event when a listview is left-clicked on an empty space - i.e. clicking on no item within the listview control.

我在列表视图的事件列表中进行搜索,但没有发现。我怎样才能做到这一点?
请帮助!

I've search in the Events list of the listview but found none. How can I do this? Please help!


我想如果我能抓住这个事件:取消选择在ListView中的所有项目

What I want to do if I could catch this event: Deselect all items in the listview.

推荐答案

如果您将一个处理器上会被点击一个ListViewItem的以外的地区时,只有火在ListView MouseLeftButtonDown事件。项目内的任何点击将通过项目本身进行处理来驱动ListView的选择行为。

If you attach a handler to the MouseLeftButtonDown event on the ListView it will only fire when areas outside of a ListViewItem are clicked. Any clicks inside the items will be handled by the items themselves to drive the ListView's selection behavior.

您可以通过调整背景(无法点击,别的是空{X})进行更改可点击区域。还要确保你没有使用上ListView控件本身就是一个空的背景(白色是默认的,透明的作品太)。

You can make changes to the clickable areas by adjusting the Background ({x:Null} is not clickable, anything else is) and Margin of the ListViewItems by setting an ItemContainerStyle on the ListView. Also make sure that you are not using a null Background on the ListView itself (White is the default, Transparent works too).

这篇关于如何处理该事件上的空白处单击时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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