Problem creating custom application theme in WP7

I am trying to create a special application theme in Windows Phone 7, but unfortunately I have encountered the following problem: If I try to change the default style and some colors, as a result the style is applied correctly, but for some reason the colors are not. I mean, my new style uses default colors instead of custom ones.

That's what I'm doing:

1.I created a folder called CustomTheme with two ResourceDictionaries:

Brushes.xaml

Styles.xaml

2.Next I added them to App.xaml as follows:

<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 the Style sample from Styles.xaml as follows:

 <TextBox Style="{StaticResource SomeStyle}"/> 

4. As a result, the style is applied as expected (I mean that the ControlTemplate is changed), but with the default colors instead of those specified in Brushes.xaml

I managed to find a workaround by adding Brushes.xaml to my Styles.xaml file, and not to App.xaml:

 <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Brushes.xaml"/> </ResourceDictionary.MergedDictionaries> 

I ask for suggestions. Is there a better solution to the problem? Why are colors not fused correctly?

+4
source share
1 answer

The solution you have is the best that I know and that we used when implementing RunKeeper, although we also saved the equivalent of your Brushes.xaml in App.xaml too.

Feels "broken" to be honest, but at least there is a useful workaround :)

+1
source

Source: https://habr.com/ru/post/1345075/


All Articles