From 19e3b7d819d83666eec3ed02f7615c41cb88183c Mon Sep 17 00:00:00 2001 From: David Hancock Date: Tue, 2 Jan 2024 12:11:27 +0000 Subject: [PATCH] Don't resize in loaded event At the loaded stage layout should be complete and dimensions stable. Setting the content presenter padding at load time caused a size change. --- WinUI3Controls/GroupBox/GroupBox.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/WinUI3Controls/GroupBox/GroupBox.cs b/WinUI3Controls/GroupBox/GroupBox.cs index f562a29..9d2de95 100644 --- a/WinUI3Controls/GroupBox/GroupBox.cs +++ b/WinUI3Controls/GroupBox/GroupBox.cs @@ -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()