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)