コード例 #1
0
        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;
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }