Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle the event when click on empty space?

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!

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

like image 580
Nam G VU Avatar asked Aug 24 '10 07:08

Nam G VU


1 Answers

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.

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).

like image 146
John Bowen Avatar answered Nov 15 '22 03:11

John Bowen