Wpf listview binding not updating dark dating sites

I can then remove an item from the m_Variable List collection, and it does not disappear from the List Box. I used the same XAML successfully in a test application; however, I was able to replicate the issue you are experiencing by re-instantiating the m_Variable List variable.

When the m_Variable List is given a new instance, or pointed to a new object, it is not reflected in the List Box because the control has its own reference to the data.

You can data bind a list box directly to a List, if you want.

The advantage of Observable Collection over List is that it implements INotify Collection Changed.

However, when the application loads, it doesn't update, for some reason.

I have what I believe should be simple two-way databinding in WPF setup, but the listbox (target) is not updating as the collection changes.

In order to achieve your goal one of options is to change the IItem from interface to a class which implements INotify Property Changed interface (or implement it in the IItem concrete type), and hook it with the View Model's Property Changed delegate (remember to unsubscribe it).

I'm setting this Items Source of the List Box programmatically: When I initially set the Items Source, the List Box (which is not visible at the time) gets its items set.

However, if I go view the List Box, updates seem to stop at that point. The problem is not in the XAML that you have provided.

When a view binds to an Observable Collection, it subscribes to events from that instance.

It expects to be notified when items are added, removed, or replaced within that instance of the collection.

Leave a Reply