Wpf listview selecteditem not updating


Suppose you have a collection of Person View Model instances, where the class is defined as: Also suppose that you have these resources set up, and they are applied to the List Box that displays the list of Person View Model objects: The List Box is declared as: The UI also has another List Box that is not bound to a grouped collection view, and also, beneath the List Boxs, a Text Block that shows the selected Person View Model’s Bio property. Because it turns out that the initially selected item in a List Box bound to a grouped ICollection View has its Is Selected property set to true, as a local value.

When you run the app, it looks like this: If you select Steve Smith from the left List Box, the UI updates accordingly: However, if you then select Dave Brown again from the right List Box (the one bound to grouped data), watch what happens: Yikes!! According to rules of WPF, a local value takes precedence over the value provided by a binding.

So, the binding established on the List Box Item’s Is Selected property is overwritten by a local value.

Until Microsoft fixes the bug I reported about this we are stuck using a workaround.

Find it in the new version of the list, and re-select it.



Save the selected item's key before the list is updated.

And if there are changed items, they load their content from server, while other remain intact.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>