I can see the foreground colors changing, in your example, as I wished they would in my code.
Two complexities in my code that I hadn't thought were relevant, but which seem to be:
- The fields in my forms have explicit content set, rather than the one that they would generate themselves by default.
- Rather than auto-generating the fields, the forms have templates set - and - those templates are from an external source, and are not part of the application.
In my app, the form templates are loaded from external files, and are constructed using XamlReader.Load(). But it doesn't look like it's the external loading that is the problem.
Starting with your example:
First: I created a DataTemplate that defined three DataFormDataFields, in Windows.Resources.
And I bound the form's ReadOnlyTemplate to that DataTemplate.
And the foreground colors changed as desired.
Second: I modified one the Name field in the template to use an explicit TextBox, instead of the auto-generated control.
And the foreground colors still changed as desired. Even in the explicit TextBox.
Third: I removed the form's ReadOnlyTemplate binding, and set ReadOnlyTemplate in MainWindow_Loaded()
And then, finally, I did not see the foreground color change, in the explicit TextBox.
The attachment mechanism in this forum will not allow .zip files, so I created a support ticket: 657307 to which I've attached a zip file containing this third example.