From ae1e46b586e354193eacd8c5378c0a1791effb05 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 18 Mar 2025 19:47:54 +0800 Subject: [PATCH] fix: layout horizontal not working since 2025.9 after switching away from history screen (#1108) Signed-off-by: leo --- src/Views/Histories.axaml.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index f7055dfa..84cfda2f 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -12,7 +12,7 @@ namespace SourceGit.Views public class HistoriesLayout : Grid { public static readonly StyledProperty UseHorizontalProperty = - AvaloniaProperty.Register(nameof(UseHorizontal)); + AvaloniaProperty.Register(nameof(UseHorizontal), false); public bool UseHorizontal { @@ -22,19 +22,20 @@ namespace SourceGit.Views protected override Type StyleKeyOverride => typeof(Grid); - public HistoriesLayout() - { - RefreshLayout(); - } - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); - if (change.Property == UseHorizontalProperty) + if (change.Property == UseHorizontalProperty && IsLoaded) RefreshLayout(); } + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnAttachedToVisualTree(e); + RefreshLayout(); + } + private void RefreshLayout() { if (UseHorizontal)