refactor: using command binding instead of routed event binding

This commit is contained in:
leo 2024-06-04 13:10:48 +08:00
parent d0edc09b2e
commit 863f88133c
2 changed files with 7 additions and 12 deletions

View file

@ -395,12 +395,17 @@
Classes="icon_button" Classes="icon_button"
Width="14" Width="14"
Margin="8,0" Margin="8,0"
Click="UpdateSubmodules" Command="{Binding UpdateSubmodules}"
IsVisible="{Binding Submodules, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}" IsVisible="{Binding Submodules, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}"
ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Update}"> ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Update}">
<Path x:Name="iconSubmoduleUpdate" Width="12" Height="12" Data="{StaticResource Icons.Loading}"/> <Path x:Name="iconSubmoduleUpdate" Width="12" Height="12" Data="{StaticResource Icons.Loading}"/>
</Button> </Button>
<Button Grid.Column="3" Classes="icon_button" Width="14" Margin="0,0,8,0" Command="{Binding AddSubmodule}" ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Add}"> <Button Grid.Column="3"
Classes="icon_button"
Width="14"
Margin="0,0,8,0"
Command="{Binding AddSubmodule}"
ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Add}">
<Path Width="12" Height="12" Data="{StaticResource Icons.Submodule.Add}"/> <Path Width="12" Height="12" Data="{StaticResource Icons.Submodule.Add}"/>
</Button> </Button>
</Grid> </Grid>

View file

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
@ -305,14 +303,6 @@ namespace SourceGit.Views
e.Handled = true; e.Handled = true;
} }
private void UpdateSubmodules(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.Repository repo)
repo.UpdateSubmodules();
e.Handled = true;
}
private void CollectBranchesFromNode(List<Models.Branch> outs, ViewModels.BranchTreeNode node) private void CollectBranchesFromNode(List<Models.Branch> outs, ViewModels.BranchTreeNode node)
{ {