是否可以创建自定义主题并将其用作默认主题?
我可以在任何地方找到的每个示例都说您可以通过复制 ThemeResources.xaml
来创建自定义主题。和 System.Windows.xaml
文件并将它们作为合并字典包含在您的应用程序中。
http://windowsphonegeek.com/articles/Creating-WP7-Custom-Theme-ndash-Basic-Theme-Implementation
Overriding themes in Windows Phone 7
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/CustomThemeResources.xaml" />
<ResourceDictionary Source="Resources/CustomThemeStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
然后我阅读了更多关于您需要在样式文件中包含画笔的内容,因此在
CustomThemeStyles.xaml
中我有这个。http://www.windowsphonegeek.com/articles/Creating-WP7-Custom-Theme---Complex-Theme
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CustomThemeResources.xaml" />
</ResourceDictionary.MergedDictionaries>
它不起作用...所以我下载了示例应用程序,果然,每个想要更改颜色(如背景颜色)的页面都会将其设置在最外层组件上。
<Grid Background="{StaticResource PhoneBackgroundBrush}">
...
</Grid>
是否可以包含更改所有默认值的样式/画笔/颜色/等的自定义主题,而无需在任何地方显式设置它们?
最佳答案
在当前版本的 WP7 中不可能有一个新的样式来更改默认样式而不通过“x:Key”明确设置它:
隐式样式是 Silverlight 4(和 WPF)的一个特性:Windows Phone 7 基于 Silverlight 3+(添加了一些 Silverlight 4 特性)。由于 Silverlight 3 中没有隐式样式,这意味着也无法在 Windows Phone 7 中使用它们。
现在你可以:
最后,如 德里克·莱金 之前提到过:希望这个错误会在 Mango 更新中得到修复!
关于xaml - 覆盖默认主题 WP7 的自定义主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5658951/