Merge pull request #194 from irihitech/issues/192

Fix Multi ComboBox issues.
This commit is contained in:
Dong Bin
2024-03-27 22:06:47 +08:00
committed by GitHub
5 changed files with 16 additions and 4 deletions

View File

@@ -17,7 +17,8 @@
InnerLeftContent="Left"
InnerRightContent="Right"
Classes="ClearButton"
ItemsSource="{Binding Items}" />
ItemsSource="{Binding Items}" >
</u:MultiComboBox>
<ListBox ItemsSource="{Binding #combo.SelectedItems}" />
</StackPanel>
</UserControl>

View File

@@ -50,6 +50,7 @@
HorizontalScrollBarVisibility="Disabled">
<u:MultiComboBoxSelectedItemList
VerticalAlignment="Center"
ItemTemplate="{TemplateBinding SelectedItemTemplate}"
ItemsSource="{TemplateBinding SelectedItems}"
RemoveCommand="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Remove}">
<ItemsControl.ItemsPanel>

View File

@@ -121,11 +121,12 @@
Data="{DynamicResource ClosableTagCloseIconGlyph}"
DockPanel.Dock="Right"
Foreground="{TemplateBinding Foreground}" />
<TextBlock
<ContentPresenter
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="12"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Content}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
TextTrimming="CharacterEllipsis" />
</DockPanel>
</Border>

View File

@@ -79,6 +79,15 @@ public class MultiComboBox: SelectingItemsControl, IInnerContentControl
get => GetValue(InnerRightContentProperty);
set => SetValue(InnerRightContentProperty, value);
}
public static readonly StyledProperty<IDataTemplate?> SelectedItemTemplateProperty = AvaloniaProperty.Register<MultiComboBox, IDataTemplate?>(
nameof(SelectedItemTemplate));
public IDataTemplate? SelectedItemTemplate
{
get => GetValue(SelectedItemTemplateProperty);
set => SetValue(SelectedItemTemplateProperty, value);
}
static MultiComboBox()
{

View File

@@ -87,7 +87,7 @@ public class MultiComboBoxItem: ContentControl
e.InitialPressMouseButton is MouseButton.Left or MouseButton.Right)
{
var point = e.GetCurrentPoint(this);
if (new Rect(Bounds.Size).ContainsExclusive(point.Position))
if (new Rect(Bounds.Size).ContainsExclusive(point.Position) && e.Pointer.Type == PointerType.Touch)
{
this.IsSelected = !this.IsSelected;
e.Handled = true;