diff --git a/demo/Ursa.Demo/Pages/MultiComboBoxDemo.axaml b/demo/Ursa.Demo/Pages/MultiComboBoxDemo.axaml index 38e5b3a..28ff9fc 100644 --- a/demo/Ursa.Demo/Pages/MultiComboBoxDemo.axaml +++ b/demo/Ursa.Demo/Pages/MultiComboBoxDemo.axaml @@ -59,6 +59,8 @@ option 1 option 2 option 3 + + diff --git a/src/Ursa.Themes.Semi/Controls/TagInput.axaml b/src/Ursa.Themes.Semi/Controls/TagInput.axaml index 1e865f6..88e0136 100644 --- a/src/Ursa.Themes.Semi/Controls/TagInput.axaml +++ b/src/Ursa.Themes.Semi/Controls/TagInput.axaml @@ -135,7 +135,14 @@ Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding}" Content="{StaticResource ClosableTagCloseIconGlyph}" /> + ReferenceEquals(a, data)); if (item is not null) diff --git a/src/Ursa/Controls/ComboBox/MultiComboBoxSelectedItemList.cs b/src/Ursa/Controls/ComboBox/MultiComboBoxSelectedItemList.cs index 4f23fd3..1925918 100644 --- a/src/Ursa/Controls/ComboBox/MultiComboBoxSelectedItemList.cs +++ b/src/Ursa/Controls/ComboBox/MultiComboBoxSelectedItemList.cs @@ -1,6 +1,8 @@ using System.Windows.Input; using Avalonia; using Avalonia.Controls; +using Avalonia.Layout; +using Avalonia.Media; namespace Ursa.Controls; @@ -31,6 +33,15 @@ public class MultiComboBoxSelectedItemList: ItemsControl if (container is ClosableTag tag) { tag.Command = RemoveCommand; + if (item is Layoutable visualContent) + { + tag.VisualContent = new VisualBrush + { + Visual = visualContent, + }; + tag.VisualContentWidth = visualContent.Bounds.Width; + tag.VisualContentHeight = visualContent.Bounds.Height; + } } } } \ No newline at end of file diff --git a/src/Ursa/Controls/TagInput/ClosableTag.cs b/src/Ursa/Controls/TagInput/ClosableTag.cs index 8aa403a..9d972e8 100644 --- a/src/Ursa/Controls/TagInput/ClosableTag.cs +++ b/src/Ursa/Controls/TagInput/ClosableTag.cs @@ -2,6 +2,7 @@ using System.Windows.Input; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; +using Avalonia.Media; namespace Ursa.Controls; @@ -12,10 +13,37 @@ public class ClosableTag : ContentControl public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register( nameof(Command)); + + public static readonly StyledProperty VisualContentProperty = AvaloniaProperty.Register( + nameof(VisualContent)); + + public static readonly StyledProperty VisualContentWidthProperty = AvaloniaProperty.Register( + nameof(VisualContentWidth)); + + public static readonly StyledProperty VisualContentHeightProperty = AvaloniaProperty.Register( + nameof(VisualContentHeight)); public ICommand? Command { get => GetValue(CommandProperty); set => SetValue(CommandProperty, value); } + + public VisualBrush? VisualContent + { + get => GetValue(VisualContentProperty); + set => SetValue(VisualContentProperty, value); + } + + public double? VisualContentWidth + { + get => GetValue(VisualContentWidthProperty); + set => SetValue(VisualContentWidthProperty, value); + } + + public double? VisualContentHeight + { + get => GetValue(VisualContentHeightProperty); + set => SetValue(VisualContentHeightProperty, value); + } } \ No newline at end of file