public override void Clear()
{
if (_isItemsHost)
base.Clear();
else
{
VerifyWriteAccess();
// Make a copy of all contained elements
UIElement[] elements = _externalChildren.ToArray();
// Remove all the external list entries
_externalChildren.Clear();
// Instruct the visual parent it must measure with the change in state
_visualParent.InvalidateMeasure();
// Actual elements are removed from internal collection once removed animation completes
OnUIElementsRemove(new UIElementsEventArgs(elements));
}
}