动态改变隐式风格 [英] Dynamically change implicit style

查看:20
本文介绍了动态改变隐式风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我的应用程序中有一些隐式样式的 TabItem.我想为我的应用添加夜间模式"并改变我的风格.我应该怎么做?

Right now I have some TabItems in my App which are implicitly styled. I want to add a "Night mode" to my app and change my style. How should I go about this?

推荐答案

Alfonso 的想法是正确的...但是你必须在 WPF 中这样做

Alfonso was right in idea... but you have to do it like this in WPF

App.Current.Resources.MergedDictionaries.Clear(); 
Uri uri = new Uri("/Resources/GlassButton5Night.xaml", UriKind.Relative);
var resDict = Application.LoadComponent(uri) as ResourceDictionary;
App.Current.Resources.MergedDictionaries.Add(resDict);

并且您已确保将 MergedDictionaries 重置为正确的级别

And you have make sure you reset your MergedDictionaries at the right level

这篇关于动态改变隐式风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆