feat: init

This commit is contained in:
rabbitism
2024-03-22 22:02:00 +08:00
parent eb1eda582f
commit d271623a66
3 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
namespace Ursa.Controls;
public class MultiComboBox: SelectingItemsControl
{
private ComboBox _box;
private static ITemplate<Panel?> _defaultPanel = new FuncTemplate<Panel?>(() => new VirtualizingStackPanel());
public static readonly StyledProperty<bool> IsDropDownOpenProperty =
ComboBox.IsDropDownOpenProperty.AddOwner<MultiComboBox>();
public bool IsDropDownOpen
{
get => GetValue(IsDropDownOpenProperty);
set => SetValue(IsDropDownOpenProperty, value);
}
static MultiComboBox()
{
FocusableProperty.OverrideDefaultValue<MultiComboBox>(true);
ItemsPanelProperty.OverrideDefaultValue<MultiComboBox>(_defaultPanel);
}
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
{
return NeedsContainer<MultiComboBoxItem>(item, out recycleKey);
}
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
{
return new MultiComboBoxItem();
}
internal void ItemFocused(MultiComboBoxItem dropDownItem)
{
if (IsDropDownOpen && dropDownItem.IsFocused && dropDownItem.IsArrangeValid)
{
dropDownItem.BringIntoView();
}
}
}