WPF MVVM DataBindings stop updating WPF MVVM DataBindings stop updating wpf wpf

WPF MVVM DataBindings stop updating


After several months of debugging, I was finally able to solve the issue by attaching a debugger to the remote target. Only then did it produce an exception that I could debug. I still do not understand why AppDomain.UnhandledException and Dispatcher.UnhandledException did not catch this exception, but at least I was able to figure it out.


You might be falling victim to over-zealous weak references. There might be a fix for your MVVM framework. If not, this information might help you find the issue in the source code.

There is a known memory leak in most implementations of INotifyPropertyChanged. The view model takes a hard reference on the delegate of the XAML control's PropertyChanged handler. That delegate in turn takes a hard reference on the XAML control. Because of this, the control can't be collected as long as the view model exists.

So to fix this problem, many MVVM frameworks use weak references for events. While this can fix the memory leak, it can also cause the problem that you are seeing. If the weak event isn't properly implemented, it might be removed before the XAML control is actually collected.

I suspect that you are using an MVVM framework with weak references, and that they are getting prematurely disposed. To see if this is a likely issue, put a few calls to GC.Collect() and see if the problem occurs more frequently.