ListView gets out of sync

Apr 6, 2011 at 10:33 PM

I am in a WPF rat hole...and would very much appreciate help.

I have a treeview. When the user clicks on a node, I display a listview with an itemtemplate of a radiobutton and a textblock.  The ItemsSource is static and is used for every object in the tree.

The itemsSource is a collection of objects with two properties, IsChecked, TextBlock.

When a user clicks on a different treenode, I need to set one of the radio buttons in the listview control to checked that corresponds with a value in the treenode object.

Likewise, if a user interacts with the listview by clicking on a radio button, I need to set a value in the object that represents the treenode.

The problem is in the timing. When a user switches back and forth quickly between two treenodes, invariably the wrong object ends up losing its value.  I believe this happens because the

current treenode gets updated, but the control lags behind slightly.

Does anyone have an example of a listview with radio buttons where the itemssource is in the viewmodel and the object that is checked is stored in the model. (I can only get this to work if I store

the entire collection in each object). Hope this makes sense!

Apr 8, 2011 at 4:53 PM

The issue for me turned out to be that the control was not being updated. Once I reset the ItemsSource or otherwise caused a NotifyPropertyChanged to fire on my ItemsSource binding, the problem went away.