diff --git a/demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml b/demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml
index 82d1737..5816d12 100644
--- a/demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml
+++ b/demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml
@@ -31,17 +31,22 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs
index 0261bd0..998bb41 100644
--- a/demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs
@@ -3,8 +3,9 @@ using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.ViewModels;
-public class TreeComboBoxDemoViewModel: ObservableObject
+public partial class TreeComboBoxDemoViewModel: ObservableObject
{
+ [ObservableProperty] private TreeComboBoxItemViewModel? _selectedItem;
public List Items { get; set; }
public TreeComboBoxDemoViewModel()
diff --git a/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml b/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
index 97f3fbc..42dbb78 100644
--- a/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
+++ b/src/Ursa.Themes.Semi/Controls/TreeComboBox.axaml
@@ -2,10 +2,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:iri="https://irihi.tech/shared"
- xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls">
+ xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"
+ xmlns:converters1="clr-namespace:Ursa.Themes.Semi.Converters">
+
@@ -17,7 +19,7 @@
-
+
+ Content="{TemplateBinding SelectionBoxItem}">
+
+
+
+
+
+
+
-
-
+
+
+
+ IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
values, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if(values.Count>0 && values[0] is IDataTemplate template1)
+ {
+ return template1;
+ }
+ if(values.Count>1 && values[1] is IDataTemplate template2)
+ {
+ return template2;
+ }
+ return AvaloniaProperty.UnsetValue;
+ }
+}
\ No newline at end of file
diff --git a/src/Ursa/Controls/ComboBox/TreeComboBox.cs b/src/Ursa/Controls/ComboBox/TreeComboBox.cs
index f39f262..2424ea4 100644
--- a/src/Ursa/Controls/ComboBox/TreeComboBox.cs
+++ b/src/Ursa/Controls/ComboBox/TreeComboBox.cs
@@ -4,19 +4,21 @@ using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Shapes;
using Avalonia.Controls.Templates;
+using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Metadata;
using Avalonia.VisualTree;
using Irihi.Avalonia.Shared.Common;
+using Irihi.Avalonia.Shared.Contracts;
using Size = Avalonia.Size;
namespace Ursa.Controls;
[TemplatePart(PartNames.PART_Popup, typeof(Popup))]
-public class TreeComboBox: ItemsControl
+public class TreeComboBox: ItemsControl, IClearControl
{
private Popup? _popup;
@@ -89,8 +91,10 @@ public class TreeComboBox: ItemsControl
private object? _selectedItem;
- public static readonly DirectProperty SelectedItemProperty = AvaloniaProperty.RegisterDirect(
- nameof(SelectedItem), o => o.SelectedItem, (o, v) => o.SelectedItem = v);
+ public static readonly DirectProperty SelectedItemProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(SelectedItem), o => o.SelectedItem, (o, v) => o.SelectedItem = v,
+ defaultBindingMode: BindingMode.TwoWay);
public object? SelectedItem
{
@@ -284,4 +288,9 @@ public class TreeComboBox: ItemsControl
treeComboBoxItem.IsSelected = selected;
}
}
+
+ public void Clear()
+ {
+ SelectedItem = null;
+ }
}
\ No newline at end of file