Skip to content

Commit

Permalink
Cache children
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed May 11, 2024
1 parent 43bd398 commit 5056720
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/Core/src/Platform/Windows/ContentPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal FrameworkElement? Content
public ContentPanel()
{
_borderPath = new Path();
EnsureBorderPath();
EnsureBorderPath(containsCheck: false);

SizeChanged += ContentPanelSizeChanged;
}
Expand All @@ -72,9 +72,18 @@ void ContentPanelSizeChanged(object sender, SizeChangedEventArgs e)
UpdateClip(_borderStroke?.Shape, width, height);
}

internal void EnsureBorderPath()
internal void EnsureBorderPath(bool containsCheck = true)
{
if (!Children.Contains(_borderPath))
if (containsCheck)
{
var children = Children;

if (!children.Contains(_borderPath))
{
children.Add(_borderPath);
}
}
else
{
Children.Add(_borderPath);
}
Expand Down Expand Up @@ -140,8 +149,12 @@ void AddContent(FrameworkElement? content)
return;
}

if (!Children.Contains(_content))
Children.Add(_content);
var children = Children;

if (!children.Contains(_content))
{
children.Add(_content);
}
}

void UpdateClip(IShape? borderShape, double width, double height)
Expand Down

0 comments on commit 5056720

Please sign in to comment.