我有一堆
Colors
几分钟内
ResourceDicitonaries
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:s="clr-namespace:System;assembly=netstandard">
<Color x:Key="Color.Background">#301536</Color>
</ResourceDictionary>
我只是把两者都加到
App.xaml
像这样:
<!--Colors-->
<ResourceDictionary Source="Resources/Colors/Light.xaml"/>
<ResourceDictionary Source="Resources/Colors/Dark.xaml"/>
这个
ResourceDicitonary
文件只是一个
.xaml
没有任何绑定的文件
.cs
,并且这两个词典都设置在
应用程序xaml
而不必在
MergedDicionaries
组。
Color
从代码中,我找不到它,看起来它没有添加到资源列表中。
var color = Application.Current.Resources.FirstOrDefault(f => f.Key == "Color.Background")
.Value as Color? ?? Color.Crimson;
有什么方法可以访问这样的资源吗
FindResource/TryFindResource
我还尝试访问/查看
MergedDictionaries