protected DataTemplate Find(ResourceDictionary resource, string key) { var template = resource.FirstOrDefault(o => o.Key.ToString() == key).Value as DataTemplate; if (template != null) return template; foreach (var merge in resource.MergedDictionaries) { template = Find(merge, key); if (template != null) return template; } return null; }
protected DataTemplate Find(ResourceDictionary resource, string key) { var template = resource.FirstOrDefault(o => o.Key.ToString() == key).Value as DataTemplate; if (template != null) { return(template); } foreach (var merge in resource.MergedDictionaries) { template = Find(merge, key); if (template != null) { return(template); } } return(null); }
public static object TryFindResource(this ResourceDictionary This, object key) { var ret = This .FirstOrDefault(x => x.Key.Equals(key)) .Value; if (ret != null) { return(ret); } foreach (var subDictionary in This.MergedDictionaries) { ret = subDictionary.TryFindResource(key); if (ret != null) { return(ret); } } return(null); }