Problem when creating custom application theme in WP7
I am trying to create a custom application theme in Windows Phone 7 but unfortunately faced the following problem: If I try to change a Style and some of the default co开发者_如何学编程lors, as a result the Style is applied correctly but for some reason the colors are not. I mean my new Style uses the default colors instead of the custom ones.
Here is what I am doing:
1.I created a folder named CustomTheme with two ResourceDictionaries:
Brushes.xaml
Styles.xaml
2.Next I added them into App.xaml in this way:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CustomTheme/Brushes.xaml"/>
<ResourceDictionary Source="CustomTheme/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
3. After that I tried to use a sample Style from Styles.xaml in this way:
<TextBox Style="{StaticResource SomeStyle}"/>
4.As a result the Style is applied as expected(I mean the ControlTemplate is changed) but with the default colors instead of these specified in Brushes.xaml
I managed to find a workaround of the problem by adding Brushes.xaml in my Styles.xaml file instead of in App.xaml:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Brushes.xaml"/>
</ResourceDictionary.MergedDictionaries>
I am asking for a suggestion. Is there a better solution of the problem? Why are the colors not merged correctly?
The solution that you have is the best that I know and is what we used when implementing RunKeeper, though we did also keep the equivalent of your Brushes.xaml in App.xaml, too.
Feels "broken" to be honest, but at least there's a usable workaround :)
精彩评论