There is a strange bug in ListView/GridView in WPF when the SelectionMode is set to Single.
Ways to reproduce:
Generate a collection (the collection must have enough items so that the ListView can at least scroll 2-3 pages):
var customers = from c in _db.Customers
orderby c.Name, c.City
select c;
Bind the collection to the ListView:
dataGrid.ItemsSource = customers.ToList();
On the first page, change your selection 3-4 items. Remember which items you previously selected. Scroll down using mouse wheel, so that you are on the next page. Scroll back up. Voila!! You will see all the items you clicked selected?! Image of this error: http://img261.imageshack.us/img261/133/listview.jpg
This same issue plagues Wpf toolkit's datagrid too.
Even stranger is that every selection is appended to SelectedItems property. So if you changed your selection 10 times, you will have 10 items in SelectedItems property with the current selection as the last item.
Can somebody tell me why this is happening? Is this intended or a bug? Seems more like a bug to me.
Somebody else too encountered this bug. Old article, but the bug still remains: http://cs.blueberryislandmedia.com/blogs/blueberries/archive/2009/04/24/bug-in-wpf-listview-single-selection-mode.aspx