views:

191

answers:

1

I have a situation where I load a WPF PRISM module into the program when the user clicks a button. The program looks at a ComboBox SelectedItem property on the already loaded module to pick data for the datacontext of the new module. Then it loads data from a database into the datacontext of the new module. This sets the properties of my databound controls on the new module's view.

Now when I close (unload) this module again, then take another item from my Combobox and reload the module, the context of the module fills with correct data, but my view in this module is not updated.

I have implemented INotifyPropertyChanged on the properties bound to the controls on this module, however they do not seem to update automatically. The old data, from the first time this module was loaded, seem to stay in controls.

Only when I set my datacontext of the loaded module back to NULL on unloading, and then relaod it updates the view of the module.

This however feels like a hack, not really how it's supposed to be. Does anybody have any idea why the view of this module does not seem to update itself when the data in the context changes after reloading?

A: 

My (probably simplistic) understanding is that the view is not notified of DataContext changed (you only have PropertyChanged on properties not on the DataContext).

But you might also want to look at

http://blogs.msdn.com/b/delay/archive/2010/05/11/we-ve-secretly-changed-this-control-s-datacontext-let-s-see-if-it-notices-workaround-for-a-silverlight-data-binding-bug-affecting-various-scenarios-including-datagrid-contextmenu.aspx

NVM