diff --git a/demo/Ursa.Demo/Pages/TagInputDemo.axaml b/demo/Ursa.Demo/Pages/TagInputDemo.axaml
index 4cc5c4a..d73fcb3 100644
--- a/demo/Ursa.Demo/Pages/TagInputDemo.axaml
+++ b/demo/Ursa.Demo/Pages/TagInputDemo.axaml
@@ -8,5 +8,8 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
-
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Controls/TagInput.axaml b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
index 9539c85..4443f32 100644
--- a/src/Ursa.Themes.Semi/Controls/TagInput.axaml
+++ b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
@@ -9,10 +9,7 @@
-
+
@@ -24,6 +21,7 @@
CornerRadius="3">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa/Controls/TagInput/ClosableTag.cs b/src/Ursa/Controls/TagInput/ClosableTag.cs
new file mode 100644
index 0000000..de609f2
--- /dev/null
+++ b/src/Ursa/Controls/TagInput/ClosableTag.cs
@@ -0,0 +1,46 @@
+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
+{
+ public const string PART_CloseButton = "PART_CloseButton";
+ private PathIcon? _icon;
+ public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(
+ nameof(Command));
+
+ public ICommand? Command
+ {
+ 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
diff --git a/src/Ursa/Controls/TagInput/TagInput.cs b/src/Ursa/Controls/TagInput/TagInput.cs
index 21bde20..c2115ee 100644
--- a/src/Ursa/Controls/TagInput/TagInput.cs
+++ b/src/Ursa/Controls/TagInput/TagInput.cs
@@ -1,21 +1,29 @@
using System.Collections;
+using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
+using Avalonia.Controls.Metadata;
+using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
+using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Styling;
namespace Ursa.Controls;
+[TemplatePart (PART_ItemsControl, typeof (ItemsControl))]
public class TagInput: TemplatedControl
{
+ public const string PART_ItemsControl = "PART_ItemsControl";
+
+ private readonly TextBox _textBox;
+ private ItemsControl? _itemsControl;
+
+
public static readonly StyledProperty> TagsProperty = AvaloniaProperty.Register>(
nameof(Tags));
-
- private TextBox _textBox;
-
public IList Tags
{
get => GetValue(TagsProperty);
@@ -24,7 +32,6 @@ public class TagInput: TemplatedControl
public static readonly StyledProperty ItemsProperty = AvaloniaProperty.Register(
nameof(Items));
-
public IList Items
{
get => GetValue(ItemsProperty);
@@ -34,6 +41,9 @@ public class TagInput: TemplatedControl
public TagInput()
{
_textBox = new TextBox();
+ _textBox.KeyDown += OnTextBoxKeyDown;
+ Items = new AvaloniaList