问题
Hi im Currently developing a App for a Customer and the Customer wants a specific theme that matches there company colors.
and i am now trying to override the default themes so the customers theme will always be the ones used. I have currently tried the way from this this site :
http://www.geekchamp.com/articles/windows-phone-mango-custom-application-theme-step-by-step
and also some suggestions from these :
How to force to use light theme in Windows Phone 7? http://matthiasshapiro.com/2011/01/17/theme-forcing-for-windows-phone-7-silverlight/
these are some old post indeed but most should be the same in Windows phone 8
i cant get any of these to work even with moving the ThemeResource,xaml to the project and link it like wise :
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/ThemeResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
it stil uses the phones default theme Dark.
how ever i found out that if you dont use the default variables names like : PhoneBackgroundBrush
and use you own naming conventions then this works. I would prefer to just override the default variable names.
my problem is very like this on this post : Custom Theme That Overrides Default Theme WP7
Is there Really no way to override the default theme and its Variables or am i forced to make my own and go through all my controls to use my own naming convention ?
any help is very much appreciated.
regards Jens Simonsen
回答1:
In the default Resource Dictionary(s) at the bottom you'll see statements like;
<Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}"/>
Comment them out or whatever and use the same thing at the bottom of your own Resource Dictionary instead with like;
<Style TargetType="Button" BasedOn="{StaticResource MyCustomButtonStyle}"/>
After that anything of that Type should inherit your Style Templates instead of the default ones and effectively apply your theme globally without having to implicitly define them all over the place.
Hope this helps.
来源:https://stackoverflow.com/questions/16150583/windows-phone-8-theme-override-of-default-theme-not-working