in src/Microsoft.Xaml.Behaviors/Layout/FluidMoveBehavior.cs [131:187]
private void AssociatedObject_LayoutUpdated(object sender, EventArgs e)
{
if (!this.IsActive)
{
return;
}
// if it's been long enough since our last purge, then let's kick one off. Since we can't control how often layout runs, and some
// objects could reappear on the very next layout pass, we'll purge any tag who hasn't been seen since the purge tick before that.
//
// If we got a notification when elements were deleted, we would maintain a far shorter list of tags whose FEs were deleted since the last purge.
//
// We might also be able to use a WeakReference solution here, but this one is pretty cheap as it only runs when Layout is running anyway.
if (DateTime.Now - lastPurgeTick >= minTickDelta)
{
List<object> deadTags = null;
foreach (KeyValuePair<object, TagData> pair in TagDictionary)
{
if (pair.Value.Timestamp < nextToLastPurgeTick)
{
if (deadTags == null)
{
deadTags = new List<object>();
}
deadTags.Add(pair.Key);
}
}
if (deadTags != null)
{
foreach (object tag in deadTags)
{
TagDictionary.Remove(tag);
}
}
nextToLastPurgeTick = lastPurgeTick;
lastPurgeTick = DateTime.Now;
}
if (this.AppliesTo == FluidMoveScope.Self)
{
this.UpdateLayoutTransition(this.AssociatedObject);
}
else
{
Panel panel = this.AssociatedObject as Panel;
if (panel != null)
{
foreach (FrameworkElement child in panel.Children)
{
this.UpdateLayoutTransition(child);
}
}
}
}