views:

25

answers:

1

I have a configuration object that contains values to be populated to the UI. This object is serializable to an XML file so the user can save and load the current state of the GUI on the fly. The object itself is a property I've added to my code-behind for a XAML window.

If each of the UI controls in this Window are bound to a property within the configuration object, can I replace the object with a deserialized copy of the configuration XML file at runtime, and expect the UI controls to automatically attach to the new object?

Alternatively, is there a trickle-down call I can make on the Window to notify all child controls to update their bindings specified in the XAML?

Or do I have to go to each item individually and reset the source item every time?

+1  A: 

It depends on how the UI elements are bound to the configuration object. If they are going through a separate property containing the object (such as binding to Configuration.ConfigParam, where Configuration is a property of your DataContext object), then setting a new value to Configuration will work as long as either Configuration is a DependencyProperty or the class containing the Configuration property implements INotifyPropertyChanged for the Configuration property.

Dan Bryant