我有一个看起来像这样的 app.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Foo.App">
<Application.Resources>
<!-- Application resource dictionary -->
<Color x:Key="MyRed">#ad1929</Color>
</Application.Resources>
</Application>
如果我尝试像这样引用我的一种颜色:
var myRed = (Color)Application.Current.Resources["MyRed"];
我得到一个例外:
System.Collections.Generic.KeyNotFoundException: The resource 'MyRed' is not present in the dictionary.
是否与尝试引用来自不同项目的资源有关?
无法弄清楚我哪里出错了......