/// <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 (this._ownerFEs != null) { Debug.Assert(this._ownerFEs.Count > 0); if (mergedDictionary._ownerFEs == null) { #if BRIDGE mergedDictionary._ownerFEs = new List <FrameworkElement>(this._ownerFEs.Count); #else mergedDictionary._ownerFEs = new WeakReferenceList(this._ownerFEs.Count); #endif } foreach (FrameworkElement fe in this._ownerFEs) { if (fe != null) { mergedDictionary.AddOwner(fe); } } } if (this._ownerApps != null) { Debug.Assert(this._ownerApps.Count > 0); if (mergedDictionary._ownerApps == null) { #if BRIDGE mergedDictionary._ownerApps = new List <Application>(this._ownerApps.Count); #else mergedDictionary._ownerApps = new WeakReferenceList(this._ownerApps.Count); #endif } foreach (Application app in _ownerApps) { if (app != null) { mergedDictionary.AddOwner(app); } } } }
private void PropagateParentOwners(ResourceDictionary mergedDictionary) { if (this.ownerFEs != null) { if (mergedDictionary.ownerFEs == null) { mergedDictionary.ownerFEs = new List<UIElement>(this.ownerFEs.Count); } for (int i = 0; i < this.ownerFEs.Count; i++) { mergedDictionary.AddOwner(this.ownerFEs[i]); } } }