Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - How to clear selection from ListView?

Tags:

.net

listview

wpf

This seems like it should be something fairly simple, but I just can't seem to get it to work.

I'd like to programatically clear the selection of the currently selected item in my ListView.

I've tried setting SelectedValue to null, setting SelectedItem to null, setting the SelectedIndex to -1, and even tried calling the UnselectAll method. In each and every case, SelectedItems.Count is still equal to one...

Any ideas?

like image 208
Sonny Boy Avatar asked Feb 23 '11 22:02

Sonny Boy


1 Answers

You must put it into an empty collection

ListView.UnselectAll();

I have read the question again. If it does not work, then the problem may be with binding. Is the ListView bound??

like image 100
PRASHANT P Avatar answered Sep 29 '22 15:09

PRASHANT P