refactor<NameHighlightedTextBlock>: use NameHighlightedTextBlock's constructor instead of functions in each caller

This commit is contained in:
leo 2024-02-28 18:55:23 +08:00
parent cfe680ffd5
commit 1149c768d3
3 changed files with 39 additions and 48 deletions

View file

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