var _1200RDUri = new Uri(String.Format(@"/aa;Component/Themes/1200Theme.xaml"), UriKind.RelativeOrAbsolute);
var _980RDUri = new Uri(String.Format(@"/aa;Component/Themes/980Theme.xaml"), UriKind.RelativeOrAbsolute);
var _1200RD = Application.LoadComponent(_1200RDUri) as ResourceDictionary;
var _980RD = Application.LoadComponent(_980RDUri) as ResourceDictionary;
if (_1200RD == null || _980RD == null)
{
return;
}
if (!IsScreenWidthAbove1200)
{
Application.Current.Resources.MergedDictionaries.Remove(_1200RD);
Application.Current.Resources.MergedDictionaries.Remove(_980RD);
Application.Current.Resources.MergedDictionaries.Add(_980RD);
}
else
{
Application.Current.Resources.MergedDictionaries.Remove(_1200RD);
Application.Current.Resources.MergedDictionaries.Remove(_980RD);
Application.Current.Resources.MergedDictionaries.Add(_1200RD);
}
 private static void ChangeAppStyle(ResourceDictionary resources, Tuple<AppTheme, Accent> oldThemeInfo, Accent newAccent, AppTheme newTheme)
{
var themeChanged = false;
if (oldThemeInfo != null)
{
var oldAccent = oldThemeInfo.Item2;
if (oldAccent != null && oldAccent.Name != newAccent.Name)
{
var key = oldAccent.Resources.Source.ToString().ToLower();
var oldAccentResource = resources.MergedDictionaries.Where(x => x.Source != null).FirstOrDefault(d => d.Source.ToString().ToLower() == key);
if (oldAccentResource != null)
{
resources.MergedDictionaries.Add(newAccent.Resources);
resources.MergedDictionaries.Remove(oldAccentResource); themeChanged = true;
}
} var oldTheme = oldThemeInfo.Item1;
if (oldTheme != null && oldTheme != newTheme)
{
var key = oldTheme.Resources.Source.ToString().ToLower();
var oldThemeResource = resources.MergedDictionaries.Where(x => x.Source != null).FirstOrDefault(d => d.Source.ToString().ToLower() == key);
if (oldThemeResource != null)
{
resources.MergedDictionaries.Add(newTheme.Resources);
resources.MergedDictionaries.Remove(oldThemeResource); themeChanged = true;
}
}
}
else
{
ChangeAppStyle(resources, newAccent, newTheme); themeChanged = true;
} if (themeChanged)
{
OnThemeChanged(newAccent, newTheme);
}
}
这段不能直接用,得看一下代码意思 Application.Current.Resources
 Resources = new ResourceDictionary {Source = resourceAddress};

最新文章

  1. C# Redis Server分布式缓存编程 --网络转载
  2. Wordpress如何开启用户注册功能
  3. C#集合-列举(Enumeration)
  4. HDU 4883 TIANKENG’s restaurant
  5. 清除行内元素之间HTML空白的几种解决方案
  6. control file sequential read 等待事件
  7. 计算机管理cmd命令行
  8. java选择排序详解
  9. Dynamics 365 Online-60000 API Limits
  10. Python 内置方法
  11. Day2 《机器学习》第二章学习笔记
  12. Lavarel Route::resource
  13. 基于【字节】操作的IO接口:InputStream、OutputStream
  14. 使用mysqlproxy实现mysql读写分离
  15. 百度分享不支持Https的解决方案--本地化
  16. ubuntu软件安装位置
  17. 微信小程序开发4之form表单与弹出层
  18. 《Gradle权威指南》--Android Gradle插件
  19. sublime text3 增加代码片段(snipper)
  20. CSS基础-DAY2

热门文章

  1. gvim 安装YCM
  2. 【bzoj1606】[Usaco2008 Dec]Hay For Sale 购买干草
  3. 用VC2010以上版本编译可以在低版本XP和2003的运行程序的方法
  4. Java性能调优之:idea变慢解决
  5. JS判断字符串长度(中文长度为2,英文长度为1)
  6. &amp;&amp;&amp;&amp;数组去重方法总结&amp;&amp;&amp;&amp;&amp;
  7. This is US 我们的生活
  8. vs写python扩展资料收集
  9. getComputedStyle/currentStyle/style之间的爱恨情仇
  10. Linux sort 命令