Il codice di esempio ha un doppio segno di uguale nell'origine del dizionario di risorse unito App.xaml per Palette.Blue.xaml. Presumo che questo sia un errore di battitura per il tuo esempio pubblicato qui, e non il tuo vero problema però.
Può essere difficile capire come collegare tutte le risorse direttamente in XAML. Il modo più semplice per farlo è dal pannello Risorse in Blend. Ho creato un'applicazione Silverlight con file di risorse denominati come il tuo esempio, quindi ho aperto il progetto in Blend e li ho collegati molto rapidamente.
App.xaml
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SilverlightApplication1.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Theme.xaml" />
<!--
<ResourceDictionary Source="Palette.Blue.xaml"/>
<ResourceDictionary Source="Template.xaml"/>
-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Theme.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Palette.Blue.xaml"/>
<ResourceDictionary Source="Template.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Template.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBox">
<Setter Property="Margin" Value="10" />
<Setter Property="Width" Value="250" />
</Style>
<Style x:Key="ReadOnlyTextBoxStyle" TargetType="TextBox">
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Margin" Value="10" />
<Setter Property="Width" Value="250" />
</Style>
</ResourceDictionary>
Palette.Blue.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="BlueSolidColorBrush" Color="SkyBlue" />
</ResourceDictionary>
MainPage.xaml
<UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="LayoutRoot" Background="Honeydew">
<TextBox Text="Read Only Textbox"
Style="{StaticResource ReadOnlyTextBoxStyle}" />
<TextBox Text="Blue Textbox"
Background="{StaticResource BlueSolidColorBrush}" />
<TextBox Text="Read Only, Blue Textbox"
Style="{StaticResource ReadOnlyTextBoxStyle}"
Background="{StaticResource BlueSolidColorBrush}" />
</StackPanel>
</UserControl>
Naturalmente, se si sta collegando le risorse provenienti da diverse assemblee che avrà un aspetto diverso. In realtà, in questo caso, suggerirei di cercare di unire i tuoi dizionari nel codice sottostante.
fonte
2010-08-12 13:12:07
è il codice completo di theme.xaml? perché penso che sia necessario solo avviarlo e terminarlo con il tag ResourceDictionary per farlo funzionare – dnr3
No, è già in un dizionario unito. Semplicemente non sembra ereditare. –