# C#/WPF ListView Binding Mystery



## FordGT90Concept (Feb 1, 2012)

I can't figure this one out.  The application says one thing and does another.  Here is what I see when it runs:





Note how The Sims 3 is listed twice.  That is the bug--it should only appear once.

That ListView is called "detectedListView" in the the screenshot below:




It should display the SourceCollection, should it not?  Note how the SourceCollection is correct.  Where is it pulling the proverbial "rabbit out of a hat?"


I can't get more information about the ghost because it literally isn't there.


----------



## Kreij (Feb 1, 2012)

Off the top of my head it looks like the DataGridView is getting the first entry and displaying it, then another entry is added to the collection and the GDV is displaying the collection without clearing existing data first (thus resulting in the duplicate entries). Try doing a DGV.Clear() everytime before reading the collection.

If the DGV is bound to the collection you may have to set the DGV binding to null, clear it and then rebind it to the collection.


----------



## FordGT90Concept (Feb 1, 2012)

DGV doesn't have a .Clear() and it doesn't look like it's binding at all.  I didn't see a parameter to set to null.


----------

