Wpf listbox observablecollection not updating

Posted by / 21-Aug-2018 02:44

Wpf listbox observablecollection not updating

I am working on the ability to add and delete rows in an observable collection.

I have User Control view with the List View bound to the Observable Collection.

Whenever I add an item to this collection, it /does/ fire an event to notify that the collection has changed, yet this isn't reflected on the GUI during run-time unless I attempt to manually resize the window as the program is running, almost as if a resizing the window forces the GUI to refresh.

The XAML for the relevant control is as follows _log Window; In the View Model constructor I initialize _log Window and wire up Log Window Collection Changed event to a handler which in turn fires a Property Changed notification. Add happens, my event listener fires and my breakpoint is hit to confirm the code gets that far as illustrated below After this my code calls the On Property Changed function which is inherited from my View Model Base, this functions fine for my other GUI elements such as labels and the like, so that almost certainly isn't the issue.

For more information, see the Binding to Collections section in the Data Binding Overview.We also have a button that we’d like to perform an action on the selected items. what I need to do to change my XAML to Bind to my data.My code for this is as follows public Main Window View Model(IDialog Service dialog Service)The Collection Changed event handler is as follows void Log Window_Collection Changed(object sender, Notify Collection Changed Event Args e)And finally when my View receives notification that it has received a new message from the Model, I add a new string to the observable collection as follows Log Window. I applied a watch to Log Window to keep track that the collection was indeed being added to, and it is as illustrated below So at this stage I'm at a loss.My GUI will only update if I resize the window in some way, otherwise there is no visual update.

wpf listbox observablecollection not updating-55wpf listbox observablecollection not updating-61wpf listbox observablecollection not updating-40

For drag and drop, the MSDN article Walkthrough: Enabling Drag and Drop on a User Control[^] has everything you need.