你如何获得 MergedDictionary xamarin 表单?

How do you get a MergedDictionary xamarin forms?

您好,我需要在运行时修改 mergedDictionary。 我有

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <themes:LightTheme />
            <themes:DarkTheme />
            <globalStyles:Labels />
            <globalStyles:Controls />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

App.Xaml(我尝试了以下但总是得到空值)但是在调试中我可以看到那些字典..

  1. Application.Current.Resources.TryGetValue("LightTheme", out var lightTheme);
  2. var theStyle= Xamarin.Forms.Application.Current.Resources.MergedDictionaries.SingleOrDefault(x => x.ContainsKey("DarkTheme"));

我错过了什么?

谢谢

刚知道怎么做

Application.Current.Resources.MergedDictionaries.OfType().FirstOrDefault();