问题描述
我目前正在为客户开发一个应用程序,客户想要一个与公司颜色相匹配的特定主题.
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 :
如何强制使用浅色主题在 Windows Phone 7 中?http://matthiasshapiro.com/2011/01/17/theme-forcing-for-windows-phone-7-silverlight/
这些确实是一些旧帖子,但大多数在 Windows phone 8 中应该是相同的
these are some old post indeed but most should be the same in Windows phone 8
即使将 ThemeResource,xaml 移动到项目并像明智地链接它,我也无法使任何这些工作:
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.
我怎么发现如果您不使用默认变量名称,例如:PhoneBackgroundBrush
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.
我的问题很像这篇文章:覆盖默认值的自定义主题主题WP7
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 ?
非常感谢任何帮助.
问候延斯西蒙森
推荐答案
在底部的默认资源字典中,您会看到类似这样的语句;
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.
希望这会有所帮助.
这篇关于Windows Phone 8 主题覆盖默认主题不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!