Domanda

Sto usando Silverlight 4 e sto cercando di integrare uno dei temi dal Silverlight 4 Toolkit da aprile.

La mia app.XAML legge come segue:

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

Quando la mia finestra principale legge

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

funziona perfettamente.Comunque vorrei usare le risorse, quindi sono andato avanti e ho fatto il seguente

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

fallisce: - (

Ho cercato di posizionare lo stile delle risorse in altri posti come l'app.Xaml ecc.

Qualcuno sa come posso usare le risorse in modo da non dover specificare il primo piano per ogni taccuino?

PS - Sto usando il tema ExpressionDark ...

Grazie in anticipo,

Mike

È stato utile?

Soluzione

Non credo di aver bisogno della parte Binding Sorgente Part.

Ho usato il seguente

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

In passato e funziona bene.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top