/// <summary> /// This sends down the owners of this ResourceDictionary into the given /// merged dictionary. We do this because whenever a merged dictionary /// changes it should invalidate all owners of its parent ResourceDictionary. /// /// Note that AddOwners throw if the merged dictionary already has one of the /// parent's owners. This implies that either we're putting a dictionary /// into its own MergedDictionaries collection or we're putting the same /// dictionary into the collection twice, neither of which are legal. /// </summary> /// <param name="mergedDictionary"></param> private void PropagateParentOwners(ResourceDictionary mergedDictionary) { if (_ownerFEs != null) { Invariant.Assert(_ownerFEs.Count > 0); if (mergedDictionary._ownerFEs == null) { mergedDictionary._ownerFEs = new WeakReferenceList(_ownerFEs.Count); } foreach (object o in _ownerFEs) { FrameworkElement fe = o as FrameworkElement; if (fe != null) mergedDictionary.AddOwner(fe); } } if (_ownerFCEs != null) { Invariant.Assert(_ownerFCEs.Count > 0); if (mergedDictionary._ownerFCEs == null) { mergedDictionary._ownerFCEs = new WeakReferenceList(_ownerFCEs.Count); } foreach (object o in _ownerFCEs) { FrameworkContentElement fce = o as FrameworkContentElement; if (fce != null) mergedDictionary.AddOwner(fce); } } if (_ownerApps != null) { Invariant.Assert(_ownerApps.Count > 0); if (mergedDictionary._ownerApps == null) { mergedDictionary._ownerApps = new WeakReferenceList(_ownerApps.Count); } foreach (object o in _ownerApps) { Application app = o as Application; if (app != null) mergedDictionary.AddOwner(app); } } }