在Xamarin中,如果我合并两个资源目录,我仍然可以对每个目录进行更改,并在搜索资源时显示它们吗?
这就是我的意思。如果我有这两个资源类:在Xamarin中,如果我合并两个资源目录,我仍然可以对每个目录进行更改,并在搜索资源时显示它们吗?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,这就是我的意思。如果我有这两个资源类: public class Theme1 : ResourceDictionary { protected Theme1() { Add(nameof(IconColor), "#111111"); Add(nameof(PageBackgroundColor), "#111111"); } public Color IconColor { get; }
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.MergedDictionaries.Add(new Theme1());
Application.Current.Resources.MergedDictionaries.Add(new Theme2());
如果在合并之后,我现在更改了主题1中某个键的值,那么在搜索资源时会反映出来吗?如果要更改MergedDictionaries值,可以直接指定一个值
App.Current.Resources["IconColor"] = Color.Blue;
不确定这是否是您的意思,但我认为这取决于您如何将它们作为静态资源或动态资源使用