internal void SetResourcesFromObject(FrameworkElement current) { while (current != null) { if (current.Resources.Count > 0) { var entries = new DictionaryEntry[current.Resources.Count]; current.Resources.CopyTo(entries, 0); entries.ForEach(x => { try { if (this.Resources[x.Key] == null) { this.Resources.Add(x.Key, x.Value); } } catch (Exception) { } }); } current = current.Parent as FrameworkElement; } }