views:

18

answers:

0

Hey guys,

TextBox.ForegroundProperty is inherited from TextElement.ForegroundProperty. Unfortunately TextBoxs DefaultStyle sets this Property again.

That means that setting TextElement.Foreground on any parent container of the TextBox does not affect the TextBoxs Foreground Color.

Do you know any elegant way to avoid this behavior? I still want the TextElements Foreground Property only to be inherited.

I found one possible solution where I set the Foreground Property in a custom style to {Binding RelativeSource={RelativeSource Self}, Path=Foreground}.

Another possibility I know would be to reset the DefaultStyle to a custom style which does not set the Foreground Property. But that would probably destroy theming and doesn't sound right to me either.

Can anyone come up with a better approach?

Thanks, TH