0

私はSilverlight4を使用しており、4月のSilverlight4ツールキットのテーマの1つを統合しようとしています。

私の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>

失敗します:-(

App.xamlなどの他の場所にリソーススタイルを配置しようとしました。

リソースの使用方法を知っている人はいるので、各TextBlockのフォアグラウンドを指定する必要はありませんか?

PS-私はExpressionDarkテーマを使用しています...

前もって感謝します、

マイク

4

1 に答える 1

3

バインディングソースの部分が必要だとは思いません。

私は以下を使用しました

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

過去に、それはうまく機能します。

于 2010-07-20T20:22:31.580 に答える