public static T?TryGet <T>(this UI.Xaml.ResourceDictionary?resources, string key)
 {
     if (resources?.ContainsKey(key) == true && resources[key] is T typed)
     {
         return(typed);
     }
     return(default);
        public static void AddLibraryResources(this UI.Xaml.ResourceDictionary resources, string key, string uri)
        {
            if (resources == null)
            {
                return;
            }

            var dictionaries = resources.MergedDictionaries;

            if (dictionaries == null)
            {
                return;
            }

            if (!resources.ContainsKey(key))
            {
                dictionaries.Add(new UI.Xaml.ResourceDictionary
                {
                    Source = new Uri(uri)
                });
            }
        }