fix: layout horizontal not working since 2025.9 after switching away from history screen (#1108)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-18 19:47:54 +08:00
parent 822452a20c
commit ae1e46b586
No known key found for this signature in database

View file

@ -12,7 +12,7 @@ namespace SourceGit.Views
public class HistoriesLayout : Grid
{
public static readonly StyledProperty<bool> UseHorizontalProperty =
AvaloniaProperty.Register<HistoriesLayout, bool>(nameof(UseHorizontal));
AvaloniaProperty.Register<HistoriesLayout, bool>(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)