2011-07-11 85 views

回答

2

我写了一个自定义资源字典实现,它在运行时选择另一个字典,而不会影响性能,并在Visual Studio设计器中工作。你会使用这样的:

<Application.Resources> 
    <custom:ThemeResourceDictionary> 
    <custom:ThemeResourceDictionary.LightResources> 
     <ResourceDictionary Source="/ThemeManagement;component/Resources/Light.xaml" /> 
    </custom:ThemeResourceDictionary.LightResources> 
    <custom:ThemeResourceDictionary.DarkResources> 
     <ResourceDictionary Source="/ThemeManagement;component/Resources/Dark.xaml" /> 
    </custom:ThemeResourceDictionary.DarkResources> 
    </custom:ThemeResourceDictionary> 
</Application.Resources> 

Light.xamlDark.xaml将包含资源具有相同的名称。

你可以得到的代码,并阅读更多关于它on my blog

+0

哇,谢谢你的详细回复。这非常有帮助。 – user700645

3

这种事情将能够确定什么主题设置为(黑暗或光明)。您可能希望将其构建到您可以绑定到您的画笔的属性中。

Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"]; 
if (v == System.Windows.Visibility.Visible) 
{ 
    // set your brush to blue 
} 
else 
{ 
    // set your brush to grey 
} 

您还可以得到与PhoneAccentBrush用户选择的强调色,如果你需要考虑到这一点为好。

+0

还有PhoneDarkThemeOpacity作为替代方式访问,返回1或0 - 您可以在这里找到所有内部WP7-Theme-Resources的完整列表作为备忘单:http://bit.ly/kzhoog: ) – Anheledir

相关问题