refactor: use DataTemplates instead of create NamedHighlightedTextBlock manually for menu item (#1216)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-20 11:05:24 +08:00
parent 5fd074a9b6
commit 41416a6bed
No known key found for this signature in database
7 changed files with 69 additions and 68 deletions

View file

@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.DeleteBranch"
x:DataType="vm:DeleteBranch">
@ -39,7 +40,9 @@
</Border>
<Border Grid.Row="1" Grid.Column="1" Height="32" IsVisible="{Binding TrackingRemoteBranch, Converter={x:Static ObjectConverters.IsNotNull}}">
<CheckBox Margin="6,0,0,0" Content="{Binding DeleteTrackingRemoteTip}" IsChecked="{Binding AlsoDeleteTrackingRemote, Mode=TwoWay}"/>
<CheckBox Margin="6,0,0,0" IsChecked="{Binding AlsoDeleteTrackingRemote, Mode=TwoWay}">
<v:NameHighlightedTextBlock Text="{Binding DeleteTrackingRemoteTip}" VerticalAlignment="Center" />
</CheckBox>
</Border>
</Grid>
</StackPanel>

View file

@ -49,12 +49,6 @@ namespace SourceGit.Views
AffectsMeasure<NameHighlightedTextBlock>(TextProperty);
}
public NameHighlightedTextBlock(string nameKey, params object[] args)
{
SetCurrentValue(TextProperty, App.Text(nameKey, args));
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center;
}
protected override Size MeasureOverride(Size availableSize)
{
var text = Text;