diff --git a/src/Ursa.Themes.Semi/Controls/TagInput.axaml b/src/Ursa.Themes.Semi/Controls/TagInput.axaml index de0526c..1e865f6 100644 --- a/src/Ursa.Themes.Semi/Controls/TagInput.axaml +++ b/src/Ursa.Themes.Semi/Controls/TagInput.axaml @@ -2,6 +2,9 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:u="https://irihi.tech/ursa"> + + + @@ -115,21 +118,23 @@ - + Width="12" + Height="12" + Margin="4,0,0,0" + Foreground="{DynamicResource SemiColorText2}" + Command="{TemplateBinding Command}" + CommandParameter="{TemplateBinding}" + Content="{StaticResource ClosableTagCloseIconGlyph}" /> + + - + \ No newline at end of file diff --git a/src/Ursa/Controls/TagInput/ClosableTag.cs b/src/Ursa/Controls/TagInput/ClosableTag.cs index de609f2..8aa403a 100644 --- a/src/Ursa/Controls/TagInput/ClosableTag.cs +++ b/src/Ursa/Controls/TagInput/ClosableTag.cs @@ -2,16 +2,14 @@ using System.Windows.Input; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; -using Avalonia.Controls.Primitives; -using Avalonia.Input; namespace Ursa.Controls; -[TemplatePart(PART_CloseButton, typeof(PathIcon))] -public class ClosableTag: ContentControl +[TemplatePart(PART_CloseButton, typeof(Button))] +public class ClosableTag : ContentControl { public const string PART_CloseButton = "PART_CloseButton"; - private PathIcon? _icon; + public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register( nameof(Command)); @@ -20,27 +18,4 @@ public class ClosableTag: ContentControl get => GetValue(CommandProperty); set => SetValue(CommandProperty, value); } - - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) - { - base.OnApplyTemplate(e); - if (_icon != null) - { - _icon.PointerPressed -= OnPointerPressed; - } - _icon = e.NameScope.Find(PART_CloseButton); - if (_icon != null) - { - _icon.PointerPressed += OnPointerPressed; - } - - } - - private void OnPointerPressed(object? sender, PointerPressedEventArgs args) - { - if (Command != null && Command.CanExecute(null)) - { - Command.Execute(this); - } - } } \ No newline at end of file