From 1c8d4d312ad96cf3e229a11616e3371b996c7d20 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 14 Jan 2025 21:02:32 +0800 Subject: [PATCH] fix: `SelectableTextBlock` does not re-draw after `Text` property changed (#906) --- src/Views/CommitBaseInfo.axaml | 24 ++++++++++++------------ src/Views/EnhancedSelectableTextBlock.cs | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 src/Views/EnhancedSelectableTextBlock.cs diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index fe1ead84..c92a3612 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -20,13 +20,13 @@ - - + + - + @@ -36,13 +36,13 @@ - - + + - + diff --git a/src/Views/EnhancedSelectableTextBlock.cs b/src/Views/EnhancedSelectableTextBlock.cs new file mode 100644 index 00000000..183b7021 --- /dev/null +++ b/src/Views/EnhancedSelectableTextBlock.cs @@ -0,0 +1,20 @@ +using System; + +using Avalonia; +using Avalonia.Controls; + +namespace SourceGit.Views +{ + public class EnhancedSelectableTextBlock : SelectableTextBlock + { + protected override Type StyleKeyOverride => typeof(SelectableTextBlock); + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == TextProperty) + UpdateLayout(); + } + } +}