本文整理汇总了C#中System.Windows.ResourceDictionary.FindDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary.FindDictionary方法的具体用法?C# ResourceDictionary.FindDictionary怎么用?C# ResourceDictionary.FindDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.ResourceDictionary
的用法示例。
在下文中一共展示了ResourceDictionary.FindDictionary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTheme
internal static void UpdateTheme(ResourceDictionary resourceDictionary, Theme theme)
{
ResourceDictionary brushResourceDictionary = resourceDictionary.FindDictionary(BrushDictionaryUri.ToString());
if (brushResourceDictionary != null)
{
if (theme == Theme.Dark)
{
brushResourceDictionary.ReplaceDictionary(LightColorDictionaryUri, DarkColorDictionaryUri);
}
else
{
brushResourceDictionary.ReplaceDictionary(DarkColorDictionaryUri, LightColorDictionaryUri);
}
}
else
{
if (theme == Theme.Dark)
{
resourceDictionary.MergedDictionaries.Add(
new ResourceDictionary()
{
Source = DarkColorDictionaryUri
});
}
else
{
resourceDictionary.MergedDictionaries.Add(
new ResourceDictionary()
{
Source = LightColorDictionaryUri
});
}
}
}
示例2: UpdateColor
private static void UpdateColor(ResourceDictionary resourceDictionary, string key, Color color)
{
if (color != null && !((color.A == 0) && (color.R == 0) && (color.G == 0) && (color.B == 0)))
{
ResourceDictionary brushResourceDictionary = resourceDictionary.FindDictionary(BrushDictionaryUri.ToString());
if (brushResourceDictionary != null)
{
ResourceDictionary oldColorResourceDictionary = brushResourceDictionary.FindDictionary(ColorDictionaryUri.ToString());
ResourceDictionary colorResourceDictionary = new ResourceDictionary()
{
Source = ColorDictionaryUri
};
colorResourceDictionary["AccentColor"] = oldColorResourceDictionary["AccentColor"];
colorResourceDictionary["ContrastColor"] = oldColorResourceDictionary["ContrastColor"];
colorResourceDictionary["SemitransparentContrastColor"] = oldColorResourceDictionary["SemitransparentContrastColor"];
colorResourceDictionary[key] = color;
brushResourceDictionary.ReplaceDictionary(ColorDictionaryUri, colorResourceDictionary);
}
}
}