using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Windows; namespace OwlCore.Wpf.Extensions { public static class ResourceDictionaryExtensions { /// /// Gets the value associated with the specified key. /// /// /// The key of the value to get. /// /// /// When this method returns, contains the value associated with the specified key, /// if the key is found; otherwise, null. This parameter is passed uninitialized. /// /// /// true if the contains an element with the specified key; otherwise, false. /// public static bool TryGetValue(this ResourceDictionary dict, object key, [MaybeNullWhen(false)] out object value) { try { value = dict[key]; return true; } catch (KeyNotFoundException) { value = null; return false; } } } }