fix(ui): default-expand diff tree; reliable row-click toggle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-05-19 11:50:36 +02:00
parent 232d7cb647
commit 7e3ae704fe
3 changed files with 8 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ public sealed partial class WorktreeNodeViewModel : ViewModelBase
public bool IsDirectory { get; init; }
public string RelativePath { get; init; } = "";
public ObservableCollection<WorktreeNodeViewModel> Children { get; } = new();
[ObservableProperty] private bool _isExpanded = true;
}
public sealed partial class WorktreeModalViewModel : ViewModelBase

View File

@@ -56,6 +56,11 @@
SelectedItem="{Binding SelectedNode, Mode=TwoWay}"
Background="Transparent"
Margin="8,0,4,8">
<TreeView.Styles>
<Style Selector="TreeViewItem" x:DataType="vm:WorktreeNodeViewModel">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
</TreeView.Styles>
<TreeView.ItemTemplate>
<TreeDataTemplate DataType="vm:WorktreeNodeViewModel"
ItemsSource="{Binding Children}">

View File

@@ -62,9 +62,8 @@ public partial class WorktreeModalView : Window
if (sender is not Control c) return;
if (c.DataContext is not WorktreeNodeViewModel node) return;
if (!node.IsDirectory) return;
var tvi = c.FindAncestorOfType<TreeViewItem>();
if (tvi is null) return;
tvi.IsExpanded = !tvi.IsExpanded;
node.IsExpanded = !node.IsExpanded;
e.Handled = true;
}
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)