I have an action Edit
in my WPF application, which is bound to items in a ListView
control, i.e. it is executed when an item is double clicked or the Edit
button in the toolbar is clicked. This action in turn displays a modal window with the editing stuff.
Now when I select multiple items in the list, click Edit, the items stay selected in the background, also, when I close the dialog, they are still selected in the sence that their background is blue. However, they seem to be not selected in the sence that the Edit button is disabled in the toolbar (the Edit action's CanExecute
method simply checks FileList.SelectedIndex != -1
. What's more, the "selected" items won't get deselected when I click some other list item - they only get deselected when I explicitly click on them one by one - it's as if the blue background is stuck on them.
My code does not use any fancy ListView
styles or what not, so what could be causing this ?
I can post my code upon request, but it is pretty much standard.
EDIT:
After cutting down my code I finally found what's causing this issue. After showing the dialog, I edit the items in the data bound collection, so that the ListView would get updated (i.e. replace the bound objects to new objects). The question is, why is this causing a problem and how should I resolve it ?