I am using both XamTextEditor and XamMaskedEditor in a container control (Xceed DataCell) that changes its background colour depending on whether it is in edit mode or not. To not obscure this background effect, I have set the Background of the XamTextEditor and XamMaskedEditor controls to Transparent.
However, it seems that XamTextEditor automatically adjusts its Foreground according to the containing control's background colour, but XamMaskedEditor does not. This is particularly prominent in when using 'Windows XP' theme/style with the colour scheme set to 'Default (blue)'.
I tried putting the XamTextEditor and XamMaskedEditor controls on another control (a StackPanel) with its Background set to DarkBlue, but neither of the controls' Foreground changed to white; both remained black. So, it appears that the DataGrid is "telling" the editor control to change its Foreground, but it is not doing so on the XamMaskedEditor for some reason. Is this a failure on the part of the DataGrid or does the XamMaskedEditor not conform to some requirement?
I've attached an example project demonstrating this. Simply set your Display Settings to use 'Windows XP' theme, colour scheme 'Default (blue)' and then run the application. Click 'New Item' and type into both cells. The first one (which uses XamTextEditor) automatically provides a clear white Foreground against the dark blue background. The second one (which uses XamMaskedEditor) shows the standard black Foreground which is difficult to see against the dark blue background.
Unfortunately, I could not include the third-party DLLs in the attachment due to size limitation, so, as you have done previously, you will need to download and install Xceed DataGrid for WPF 3.7 control suite from here (site registration may be required).
This appears to be a bug with the XamMaskedEditor. Is there a workaround? Can this be submitted as a fix request?
Thanks,
Jason
I want to make sure I understand you before I report an issue. The title of the original post was a bit confusing since controls do not change their Foreground based on their Background. Foreground is an inherited DependencyProperty that if not set on an element is inherited from an ancestor on which it was set. In looking at the xamMaskedEditor and xamTextEditor with regards to foreground, it would seem that there are 2 issues.
First, the xamMaskedEditor's background defaults to the system Window color but the foreground is hard coded to black. The foreground should be bound to the WindowText color.
Second, while the xamTextEditor's Background defaults to the system Window color, the foreground is not set and therefore since Foreground is an inherited dependency property it will inherit the foreground of the ancestor element. Since the Background defaults to WindowBrushKey, the Foreground should default to WindowTextBrushKey. This would be consistent with what the TextBox does.
Xceed have investigated this and it appears it may be an inconsistency between the XamTextEditor and other types of control. It seems that XamTextEditor changes its Foreground colour according to the containing control's Foreground colour. However, other controls (including XamMaskedEditor) do not do this.
http://xceed.com/CS/forums/permalink/26894/26894/ShowThread.aspx#26894
Is there a resolution?