in src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Core/IncrementalUpdateBehavior.cs [328:376]
public void CachePhaseElement(FrameworkElement phaseElement, int phase)
{
if (phase < 0)
{
throw new ArgumentOutOfRangeException(nameof(phase));
}
if (phase <= 0)
{
return;
}
UIElement contentTemplateRoot = IncrementalUpdater.FindContentTemplateRoot(phaseElement);
if (contentTemplateRoot != null)
{
// get the cache for this element
ElementCacheRecord elementCacheRecord;
if (!this._elementCache.TryGetValue(contentTemplateRoot, out elementCacheRecord))
{
elementCacheRecord = new ElementCacheRecord();
this._elementCache.Add(contentTemplateRoot, elementCacheRecord);
}
// get the cache for this phase
int phaseIndex = elementCacheRecord.Phases.BinarySearch(phase);
if (phaseIndex < 0)
{
// not found - insert
phaseIndex = ~phaseIndex;
elementCacheRecord.Phases.Insert(phaseIndex, phase);
elementCacheRecord.ElementsByPhase.Insert(phaseIndex, new List<PhasedElementRecord>());
}
List<PhasedElementRecord> phasedElementRecords = elementCacheRecord.ElementsByPhase[phaseIndex];
// first see if the element is already there
for (int i = 0; i < phasedElementRecords.Count; i++)
{
if (phasedElementRecords[i].FrameworkElement == phaseElement)
{
return;
}
}
// insert the element
phasedElementRecords.Add(new PhasedElementRecord(phaseElement));
}
}