tags:

views:

44

answers:

0

Hi,

I am trying to make resources for setting the Text ForeColor by doing the following in a Resources.xaml file

<SolidColorBrush x:Key="windowsTextForeColor"></SolidColorBrush>
<SolidColorBrush x:Key="windowTextBackColor"></SolidColorBrush>

<Style TargetType="{x:Type TextBlock}">
    <Setter Property="Background" Value="{DynamicResource windowTextBackColor}"/>
    <Setter Property="Foreground" Value="{DynamicResource windowsTextForeColor}"/>
</Style>

In code, I do the following

Application.Current.Resources["windowsTextForeColor"] = 
      new SolidColorBrush(Colors.Red);

For some reason the Text for some items such as Labels get updated properly but other TextBlocks do not....I have to do something like

FLabelTextBlock.SetResourceReference(TextBlock.ForegroundProperty, "windowsTextForeColor");

for the foreground to update properly.

I thought by doing TargetType="{x:Type TextBlock}" it would target all Textblocks without the need for me to have to code that binds to the resource?

Any clues why this may be the case?

Thanks