feature: add context menu for selected change in stashes page

This commit is contained in:
leo 2024-10-17 15:37:14 +08:00
parent d0ae24b0b7
commit b23f284e21
No known key found for this signature in database
3 changed files with 80 additions and 1 deletions

View file

@ -136,7 +136,7 @@
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Change">
<Grid ColumnDefinitions="24,*">
<Grid ColumnDefinitions="24,*" Background="Transparent" ContextRequested="OnChangeContextRequested">
<v:ChangeStatusIcon Grid.Column="0" Width="14" Height="14" Change="{Binding}"/>
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Path}" Margin="4,0,0,0"/>
</Grid>

View file

@ -18,5 +18,15 @@ namespace SourceGit.Views
}
e.Handled = true;
}
private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e)
{
if (DataContext is ViewModels.StashesPage vm && sender is Grid grid)
{
var menu = vm.MakeContextMenuForChange(grid.DataContext as Models.Change);
grid.OpenContextMenu(menu);
}
e.Handled = true;
}
}
}