我正在使用silverlight 4,我试图从4月份从Silverlight 4 Toolkit集成一个主题。

我的app.xaml读取如下:

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

当我的主窗口读取

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

它完美地工作。但是,我想使用资源,所以我继续下面并做了以下

<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>
.

失败: - (

我试图将资源样式放在应用程序中的其他地方等。

任何人都知道如何使用资源,以便我不必为每个TextBlock指定前景?

ps - 我正在使用expressiondark主题...

提前感谢,

mike

有帮助吗?

解决方案

我不相信你需要绑定源部分。

我使用了以下

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

在过去,它运作良好。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top