一、查找包含制定关键字的资源
ResourceDictionary GetThemeDictionary()
{
return (from dict in Application.Current.Resources.MergedDictionaries
where dict.Contains("S_AccentBrush")
select dict).FirstOrDefault();
}
二、遍历该资源字典
ResourceDictionary resource = this.GetThemeDictionary();
foreach (var item in resource.Keys)
{
object current = resource[item.ToString()];
if (current is SolidColorBrush)
{
// Message:查找到了想要的资源
}
}
三、查找关键字
var currentColor = Application.Current.Resources[KeyAccentColor] as System.Windows.Media.Color?;
四、目标:可以动态修改资源,绑定动态属性