views:

88

answers:

1

Hi Everyone

I am using Silverlight 4 and I am trying to integrate one of the themes from the Silverlight 4 toolkit from April.

My App.xaml reads as follows:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Themes/System.Windows.Controls.Theming.ExpressionDark.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

When my main window reads

<Grid x:Name="LayoutRoot" Background="{Binding Source={StaticResource ThemeBackgroundBrush}}">
    <TextBlock Text="Test" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{Binding Source={StaticResource ThemeForegroundBrush}}" />
</Grid>

It works perfectly. However I would like to use resources so I went ahead and did the following

<Grid x:Name="LayoutRoot" Background="{Binding Source={StaticResource ThemeBackgroundBrush}}">
    <Grid.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="{Binding Source={StaticResource ThemeForegroundBrush}}" />
        </Style>
    </Grid.Resources>
    <TextBlock Text="Test" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>

It fails :-(

I have tried to place the resource style in other places like the App.xaml etc.

Anyone know how I can use resources so I don't have to specify the foreground for each TextBlock?

PS - I am using the ExpressionDark theme...

Thanks in Advance,

Mike

+2  A: 

I don't believe that you need the Binding Source part.

I have used the following

<Setter Property="Foreground" Value="{StaticResource ThemeForegroundBrush}" />

in the past and it works well.

Justin
Thanks Justing - works perfectly!
mkamioner