public override UIElement this[int index]
{
get
{
if (_isItemsHost)
return base[index];
else
return _externalChildren[index];
}
set
{
if (_isItemsHost)
base[index] = value;
else
{
if (_externalChildren[index] != value)
{
ValidateElement(value);
VerifyWriteAccess();
// 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(_externalChildren[index]));
// Update with the new value
_externalChildren[index] = value;
// Added event is always generated after the base call
OnUIElementsAdded(new UIElementsEventArgs(value));
}
}
}
}