|
@@ -650,9 +650,12 @@ namespace Avalonia
|
|
|
element._dataContextUpdating = true;
|
|
element._dataContextUpdating = true;
|
|
|
element.OnDataContextBeginUpdate();
|
|
element.OnDataContextBeginUpdate();
|
|
|
|
|
|
|
|
- foreach (var child in element.LogicalChildren)
|
|
|
|
|
|
|
+ var logicalChildren = element.LogicalChildren;
|
|
|
|
|
+ var logicalChildrenCount = logicalChildren.Count;
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < logicalChildrenCount; i++)
|
|
|
{
|
|
{
|
|
|
- if (child is StyledElement s &&
|
|
|
|
|
|
|
+ if (element.LogicalChildren[i] is StyledElement s &&
|
|
|
s.InheritanceParent == element &&
|
|
s.InheritanceParent == element &&
|
|
|
!s.IsSet(DataContextProperty))
|
|
!s.IsSet(DataContextProperty))
|
|
|
{
|
|
{
|
|
@@ -723,9 +726,15 @@ namespace Avalonia
|
|
|
AttachedToLogicalTree?.Invoke(this, e);
|
|
AttachedToLogicalTree?.Invoke(this, e);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- foreach (var child in LogicalChildren.OfType<StyledElement>())
|
|
|
|
|
|
|
+ var logicalChildren = LogicalChildren;
|
|
|
|
|
+ var logicalChildrenCount = logicalChildren.Count;
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < logicalChildrenCount; i++)
|
|
|
{
|
|
{
|
|
|
- child.OnAttachedToLogicalTreeCore(e);
|
|
|
|
|
|
|
+ if (logicalChildren[i] is StyledElement child)
|
|
|
|
|
+ {
|
|
|
|
|
+ child.OnAttachedToLogicalTreeCore(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -738,9 +747,15 @@ namespace Avalonia
|
|
|
OnDetachedFromLogicalTree(e);
|
|
OnDetachedFromLogicalTree(e);
|
|
|
DetachedFromLogicalTree?.Invoke(this, e);
|
|
DetachedFromLogicalTree?.Invoke(this, e);
|
|
|
|
|
|
|
|
- foreach (var child in LogicalChildren.OfType<StyledElement>())
|
|
|
|
|
|
|
+ var logicalChildren = LogicalChildren;
|
|
|
|
|
+ var logicalChildrenCount = logicalChildren.Count;
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < logicalChildrenCount; i++)
|
|
|
{
|
|
{
|
|
|
- child.OnDetachedFromLogicalTreeCore(e);
|
|
|
|
|
|
|
+ if (logicalChildren[i] is StyledElement child)
|
|
|
|
|
+ {
|
|
|
|
|
+ child.OnDetachedFromLogicalTreeCore(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
#if DEBUG
|