Perhaps somebody will help me out. I have been trying all day to find a solution for sharing styles and resources on my WindowsPhone project.
The problems is the following:
I have a common assembly which is used by two WP projects. Inside this assembly I have some styles and datatemplates defined. I want one of the datatemplates to be defined in the common assembly and be the default datatemplate for the projects.
Assembly resource dictionary sample code:
<Style TargetType="TextBlock" x:Key="TopItemsTitle">
<Setter Property="FontSize" Value="18"></Setter>
<Setter Property="FontFamily" Value="Segoe WP Black"></Setter>
<Setter Property="Foreground" Value="Red"></Setter>
</Style>
<DataTemplate x:Key="TopItemsTemplate">
<Button>
<TextBlock x:Name="Name"
Grid.Row="1"
Width="172"
Height="25"
Margin="0,6,0,50"
VerticalAlignment="Bottom"
Text="{Binding Name}"
TextWrapping="Wrap"
Style="{StaticResource TopItemsTitle}" />
</Button>
</DataTemplate>
Inside the different project I would like to redefine the TopItemsTitle style, for example:
<Style TargetType="TextBlock" x:Key="TopItemsTitle">
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="FontFamily" Value="Segoe WP"></Setter>
<Setter Property="Foreground" Value="Blue"></Setter>
</Style>
and then merge both resource dictionaries in the app.xaml of one the WP projects:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assembly;component/Resources/Style.xaml" />
<ResourceDictionary Source="Resources/LocalStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
According to MSDN this should be possible. However in reality this does not work. The datatemplate does not reflect the redefined style and uses the default one.
Is this a bug or am I simple do it wrong?
Any kind of help will be greatly appreciated.