/// <summary> /// This method is raised when an enumerator dispenses a ResourceDictionary. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Information about the event.</param> internal void EnumeratorResourceDictionaryDispensed(object sender, ResourceDictionaryDispensedEventArgs e) { if (!_ignoreResourceDictionaryDispensedByEnumerator) { OnEnumeratorResourceDictionaryDispensed(this, e); } }
/// <summary> /// Raises the EnumeratorResourceDictionaryDispensed event. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">Information about the event.</param> private void OnEnumeratorResourceDictionaryDispensed(object source, ResourceDictionaryDispensedEventArgs args) { // Remove this item from the list of dispensed styles. _resourceDictionariesDispensed.Remove(args); // Add this item to the end of the list of dispensed styles. _resourceDictionariesDispensed.AddLast(args); foreach (ResourceDictionaryEnumerator enumerator in _resourceDictionaryEnumerators) { enumerator.ResourceDictionaryDispenserResourceDictionaryDispensed(source, args); } }
/// <summary> /// Raises the EnumeratorResourceDictionaryDispensed. /// </summary> /// <param name="args">Information about the ResourceDictionary dispensed.</param> protected virtual void OnStyleDispensed(ResourceDictionaryDispensedEventArgs args) { ResourceDictionaryDispenser.EnumeratorResourceDictionaryDispensed(this, args); }
/// <summary> /// This method is invoked when one of the related enumerator's /// dispenses. The enumerator checks to see if the item /// dispensed would've been the next item it would have returned. If /// so it updates it's index to the position after the previously /// returned item. /// </summary> /// <param name="sender">The ResourceDictionaryDispenser.</param> /// <param name="e">Information about the event.</param> internal void ResourceDictionaryDispenserResourceDictionaryDispensed(object sender, ResourceDictionaryDispensedEventArgs e) { if (!ShouldRetrieveFromParentEnumerator && Predicate(e.ResourceDictionary)) { int?nextStyleIndex = GetIndexOfNextSuitableResourceDictionary(index ?? 0); if ((nextStyleIndex ?? -1) == e.Index) { index = (e.Index + 1) % ResourceDictionaryDispenser.ResourceDictionaries.Count; } } }