diff --git a/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml b/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
index 01642e4..97f3fbc 100644
--- a/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
+++ b/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
@@ -8,13 +8,85 @@
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -26,21 +98,81 @@
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa/Controls/ComboBox/TreeComboBox.cs b/src/Ursa/Controls/ComboBox/TreeComboBox.cs
index a20632a..8de5173 100644
--- a/src/Ursa/Controls/ComboBox/TreeComboBox.cs
+++ b/src/Ursa/Controls/ComboBox/TreeComboBox.cs
@@ -6,6 +6,7 @@ using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Layout;
+using Avalonia.LogicalTree;
using Avalonia.OpenGL.Controls;
using Irihi.Avalonia.Shared.Common;
@@ -115,24 +116,31 @@ public class TreeComboBox: SelectingItemsControl
return CreateContainerForItemOverride(item, index, recycleKey);
}
- protected override void ContainerForItemPreparedOverride(Control container, object? item, int index)
- {
- base.ContainerForItemPreparedOverride(container, item, index);
- }
-
internal void ContainerForItemPreparedInternal(Control container, object? item, int index)
{
ContainerForItemPreparedOverride(container, item, index);
}
-
+
protected override void OnPointerReleased(PointerReleasedEventArgs e)
{
base.OnPointerReleased(e);
if (e.InitialPressMouseButton == MouseButton.Left)
{
- if (_popup is not null && _popup.IsOpen && e.Source is TextBlock v && _popup.IsInsidePopup(v))
+ if (_popup is not null && _popup.IsOpen && e.Source is Visual v && _popup.IsInsidePopup(v))
{
- SelectionBoxItem = v.Text;
+ var container = v.FindLogicalAncestorOfType();
+ container?.SetValue(IsSelectedProperty, true);
+ if (container?.Header is Control control)
+ {
+ SelectionBoxItem = control.DataContext ?? control.ToString();
+ // UpdateSelectionFromEventSource(e.Source);
+
+ }
+ else
+ {
+ SelectionBoxItem = container?.Header;
+ // UpdateSelectionFromEventSource(e.Source);
+ }
SetCurrentValue(IsDropDownOpenProperty, false);
}
else
diff --git a/src/Ursa/Controls/ComboBox/TreeComboBoxItem.cs b/src/Ursa/Controls/ComboBox/TreeComboBoxItem.cs
index 887d20a..f2d3b1c 100644
--- a/src/Ursa/Controls/ComboBox/TreeComboBoxItem.cs
+++ b/src/Ursa/Controls/ComboBox/TreeComboBoxItem.cs
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Metadata;
+using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -45,6 +46,13 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
protected set => SetAndRaise(LevelProperty, ref _level, value);
}
+ static TreeComboBoxItem()
+ {
+ IsSelectedProperty.AffectsPseudoClass(PseudoClassName.PC_Selected,
+ SelectingItemsControl.IsSelectedChangedEvent);
+ PressedMixin.Attach();
+ }
+
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
@@ -57,14 +65,15 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
{
base.OnAttachedToLogicalTree(e);
_treeComboBox = this.FindLogicalAncestorOfType();
- Level = CalculateDistanceFromLogicalParent(this);
+ Level = CalculateDistanceFromLogicalParent(this) - 1;
if (this.ItemTemplate is null && this._treeComboBox?.ItemTemplate is not null)
{
SetCurrentValue(ItemTemplateProperty, this._treeComboBox.ItemTemplate);
}
-
-
-
+ if(this.ItemContainerTheme is null && this._treeComboBox?.ItemContainerTheme is not null)
+ {
+ SetCurrentValue(ItemContainerThemeProperty, this._treeComboBox.ItemContainerTheme);
+ }
}
private void OnDoubleTapped(object sender, TappedEventArgs e)
@@ -76,6 +85,8 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
{
+ TreeViewItem t = new TreeViewItem();
+ ComboBox c = new ComboBox();
return EnsureParent().NeedsContainerInternal(item, index, out recycleKey);
}
diff --git a/src/Ursa/Converters/SelectionBoxTemplateConverter.cs b/src/Ursa/Converters/SelectionBoxTemplateConverter.cs
new file mode 100644
index 0000000..3f735b7
--- /dev/null
+++ b/src/Ursa/Converters/SelectionBoxTemplateConverter.cs
@@ -0,0 +1,16 @@
+using System.Globalization;
+using Avalonia.Controls.Templates;
+using Avalonia.Data.Converters;
+
+namespace Ursa.Converters;
+
+public class SelectionBoxTemplateConverter: IMultiValueConverter
+{
+ public object? Convert(IList