Skip to content

Commit

Permalink
Don't resize in loaded event
Browse files Browse the repository at this point in the history
At the loaded stage layout should be complete and dimensions stable. Setting the content presenter padding at load time caused a size change.
  • Loading branch information
DHancock committed Jan 2, 2024
1 parent 6fa7129 commit 19e3b7d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions WinUI3Controls/GroupBox/GroupBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ protected override void OnApplyTemplate()
RegisterPropertyChangedCallback(CornerRadiusProperty, (s, d) => ((GroupBox)s).BorderPropertyChanged());
RegisterPropertyChangedCallback(BorderThicknessProperty, (s, d) => ((GroupBox)s).BorderPropertyChanged());

HeadingPresenter.SizeChanged += (s, e) =>
{
if (IsLoaded)
BorderPropertyChanged();
};
HeadingPresenter.SizeChanged += (s, e) => BorderPropertyChanged();

SizeChanged += (s, e) => ((GroupBox)s).RedrawBorder();

Loaded += (s, e) => ((GroupBox)s).RedrawBorder();

// initialise
Loaded += (s, e) => BorderPropertyChanged();
BorderPropertyChanged();
}

private void RedrawBorder()
Expand Down

0 comments on commit 19e3b7d

Please sign in to comment.