Refreshing the ViewModel's bindings to the View - is there an easy way?

Refreshing the ViewModel's bindings to the View - is there an easy way?

Old forum URL: forums.lhotka.net/forums/t/8674.aspx


skagen00 posted on Tuesday, March 16, 2010

Let's say I have a lot of properties on the ViewModel that I am binding (along with my model) to the XAML control.

Let's say my model is kind of large in size (200K hit) and I provide for a child window that allows for the editing of a few properties that affect the same data backing as my large model.

When I leave the child window, I do a small asynchronous refresh of data within the model. This effectively changes properties on the ViewModel since some of them are conditional based on the Model.

I can easily implement the property changed (on my read only object) to refresh the entirety of the model by simply iterating over the registered properties as I load them in via my asynchronous refresh of part of the model.

However, I would like to do the same sort of thing on the ViewModel, rather than having to OnPropertyChanged everything individually. I just want to say ViewModel.RefreshBindings(), but I know there isn't such a magical method available to me.

I tried to unhook my ViewModel from my View and rehook it, but that didn't seem to work. Am I missing out on something intrinsic to the ViewModelBase/ViewModel class that would automatically do this for me?

Thanks,

Chris

Copyright (c) Marimer LLC