wpf – How to obtain the selected item after Listview Binding? – Education Career Blog

I have a ListView and it’s getting updated every 5 seconds.
The problem is that the selected item vanish. How can I obtain it ?


It depends what you’re doing to update the list. If you’re deleting and re-building the list willy-nilly (which isn’t great), you’ll need to store something which can uniquely identify the selected item before deleting the list and then use that stored value to select it again once the list is repopulated. A better solution is to use something like an ObservableCollection, and try not to wipe out anything in the list unless you really need to.

Leave a Comment