Skip to content

Commit ae1e46b

Browse files
committed
fix: layout horizontal not working since 2025.9 after switching away from history screen (#1108)
Signed-off-by: leo <[email protected]>
1 parent 822452a commit ae1e46b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Views/Histories.axaml.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SourceGit.Views
1212
public class HistoriesLayout : Grid
1313
{
1414
public static readonly StyledProperty<bool> UseHorizontalProperty =
15-
AvaloniaProperty.Register<HistoriesLayout, bool>(nameof(UseHorizontal));
15+
AvaloniaProperty.Register<HistoriesLayout, bool>(nameof(UseHorizontal), false);
1616

1717
public bool UseHorizontal
1818
{
@@ -22,19 +22,20 @@ public bool UseHorizontal
2222

2323
protected override Type StyleKeyOverride => typeof(Grid);
2424

25-
public HistoriesLayout()
26-
{
27-
RefreshLayout();
28-
}
29-
3025
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
3126
{
3227
base.OnPropertyChanged(change);
3328

34-
if (change.Property == UseHorizontalProperty)
29+
if (change.Property == UseHorizontalProperty && IsLoaded)
3530
RefreshLayout();
3631
}
3732

33+
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
34+
{
35+
base.OnAttachedToVisualTree(e);
36+
RefreshLayout();
37+
}
38+
3839
private void RefreshLayout()
3940
{
4041
if (UseHorizontal)

0 commit comments

Comments
 (0)