The idea is fairly simple:
Main program made up of various UserControls.
Each UserControl has a class instances for its preferences. Thus the preferences are serializable.
WPF UserControl has TextBoxes on it with bindinds set to the code-behind properties, which get;set; to the settings object class.
Here's where it gets odd:
If the code-behind file uses a local field for the property the binding to the WPF control works.
If the code-behind file uses a property in the preferences object the binding doesn't seem to work.
Let me walk you through it:
Open the application and you have the menu on the left, and the workspace on the right is blank.
Click the Email button and the EmailSettingsDLG UserControl is made, populated and placed in the right side workspace.
Here's the code doing that:
Notice that the only TextBox that is populated is for the FromAddress and contains "Clint"
Looking at the code-behind for the window we can see the only difference between the FromAddress and the FromPassword properties is that one uses a local string field and one uses an object string property.
These breakpoints are being hit. They do confirm the values.
The XAML for the window:
As near as I can see everything is coded and binding set in exactly the same way, no typos etc.
So does WPF not work for binding to object properties? How is one supposed to serialize data objects used by GUI's then? I read a LOT that data binding is one of the strong points of shifting to WPF and that binding to GUI controls like this is one of the things lots of people do. So WTF am I doing wrong?
The only thing I can think of is that the preferences class instance is being made from the MainWindow code, and thus the MainWindow thread. And so even though execution is getting and setting these values they fail when binding to the UserControl textboxes. I do this sort of thing all the time in WinForms without a problem. Is there a way to do this in WPF?