Merge pull request #393 from irihitech/selectable

Introduce IsSelectable for TreeComboBoxItem.
This commit is contained in:
Dong Bin
2024-09-12 16:46:28 +08:00
committed by GitHub
5 changed files with 21 additions and 3 deletions

View File

@@ -217,6 +217,7 @@
<Setter Property="Background" Value="{DynamicResource TreeViewItemDefaultBackground}" />
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemDefaultForeground}" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="MinHeight" Value="32"></Setter>
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate TargetType="u:TreeComboBoxItem">

View File

@@ -198,7 +198,7 @@ public class TreeComboBox: ItemsControl, IClearControl, IInnerContentControl, IP
if (_popup is not null && _popup.IsOpen && _popup.IsInsidePopup(source))
{
var container = GetContainerFromEventSource(source);
if (container is null) return;
if (container is null || !container.IsSelectable) return;
var item = TreeItemFromContainer(container);
if (item is null) return;
if (SelectedItem is not null)

View File

@@ -33,6 +33,15 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
set => SetValue(IsExpandedProperty, value);
}
public static readonly StyledProperty<bool> IsSelectableProperty = AvaloniaProperty.Register<TreeComboBoxItem, bool>(
nameof(IsSelectable), true);
public bool IsSelectable
{
get => GetValue(IsSelectableProperty);
set => SetValue(IsSelectableProperty, value);
}
public static readonly DirectProperty<TreeComboBoxItem, int> LevelProperty = AvaloniaProperty.RegisterDirect<TreeComboBoxItem, int>(