9
votes

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?

1
Can we the XAML and some of the code? - Ray Booysen
@Drackir - Not a duplicate. I'm trying to use code behind and this has nothing to do with templates nor am I using ComboBoxes. - Sonny Boy
Sorry about the ComboBox. But I think the other solution stands whether or not you're using a codebehind. - Richard Marskell - Drackir

1 Answers

26
votes

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??