I've created a prototype app with a Listview bound to an ObservableCollection programmatically through it's itemsource property. Everything was working well until a day ago when the ListView stopped raising SelectionChanged events after the first time the event is raised. Eg. Select a row in the ListView, SelectionChanged event is raised, UI s开发者_运维知识库elects the first row in the ListView no matter what you do, then any attempts to select a row have absolutely no effect on the ListView, either in terms of selecting the row clicked on, or raising events.
So far I've established that if I remove all superflous code from the window, it does not solve the problem. If I transplant the code to a new project, it does not solve the problem. However, if I re-implement the same code by hand in a new project, the problem does not present, but the code seems identical when compared with Beyond Compare.
I also got the problem to partially disapate by clearing all selections from the listview inside the SelectionChanged event handler, which seems to resolve the issue, but means that rows never appear as selected in the Listview.
I'm at wit's end with this.
If you're using duplicate items with value types(include ref. type string also), this problem could arise as they compare the values. You can wrap your item in a class to show that the items are different. But I don't know why it worked in the new application you've created. May be you could've changed the itemssource.
精彩评论