覆盖默认主题WP7的自定义主题

| 是否可以创建自定义主题并将其用作默认主题? 我在任何地方都能找到的每个示例都说,您可以通过复制
ThemeResources.xaml
System.Windows.xaml
文件并将其作为合并的词典包含在应用程序中来创建自定义主题。 http://windowsphonegeek.com/articles/Creating-WP7-Custom-Theme-ndash-Basic-Theme-Implementation 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中使用它们。 现在,您可以: 如您指出的第一篇文章中所述,仅覆盖默认的“画笔/颜色”资源。请注意,所有WP7控件都会更改其颜色。另请注意,由于某种原因,默认背景保持不变。这是WP7当前版本的一个已知问题,可能会在““ Mango \”更新中修复。 如果要使用任何新的Style / ControlTemplate,则必须使用您指出的第二篇文章中提到的\“ x:Key \” / {StaticResource ...}方法。 最后,正如Derek Lakin先前所述:希望此错误将在Mango更新中得到修复!     
如果创建资源字典并调用它,例如Reset.xaml,其中包含所有标准画笔资源。将所有自定义资源样式/画笔放入另一个资源字典中(我们现在将其称为Custom.xaml)。在App.xaml中,包括这两个资源字典,如下所示:
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source=\"Resources/Reset.xaml\"/>
                <ResourceDictionary Source=\"Resources/Custom.xaml\"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary> 
    </Application.Resources>
从理论上讲,这应该足够了,但不幸的是,这还不够。由于某些原因(希望是芒果更新中已修复的错误),您还需要在Custom.xaml中包含Reset.xaml,如下所示:
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source=\"Reset.xaml\"/>
    </ResourceDictionary.MergedDictionaries>
完成此操作后,应该就可以了。您不需要做任何其他事情。     
随着Windows Phone Mango(7.1)的发布,合并XAML词典样式的功能不再起作用。当前,您将不得不在后面的代码中更改应用程序资源“画笔颜色”条目;最好在App.xaml.cs中的App()的构造函数中。 例:
            (App.Current.Resources[\"PhoneAccentBrush\"] as SolidColorBrush).Color = Color.FromArgb(12, 12, 54, 145);
            (App.Current.Resources[\"PhoneForegroundBrush\"] as SolidColorBrush).Color = Colors.Green;
            (App.Current.Resources[\"PhoneBackgroundBrush\"] as SolidColorBrush).Color = Colors.Purple;
希望在WP8 SDK中,我们不再需要执行此解决方法。     

要回复问题请先登录注册