这是我的情况。为本示例 Theme1 和 Theme2 标记的两个资源字典
public class Theme1 : ResourceDictionary
{
protected Theme1()
{
Add(nameof(IconColor), "#111111");
Add(nameof(PageBackgroundColor), "#111111");
}
public Color IconColor { get; }
public Color PageBackgroundColor { get;
}
public class Theme2 : ResourceDictionary
{
protected Theme2()
{
Add(nameof(IconColorA), "#222222");
Add(nameof(PageBackgroundColorA), "#222222");
}
public Color IconColorA { get; }
public Color PageBackgroundColorA { get; }
}
我想将这两个都分配给 Application.Current.Resources 但我只知道如何做一个或另一个:
Application.Current.Resources = new Theme1();
或者
Application.Current.Resources = new Theme2();
如何将两者都分配给 Application.Current.Resources?我认为在 XAML 中有一种方法可以做到这一点,但我在 C# 中找不到任何方法来做到这一点。