62
demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml
Normal file
62
demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml
Normal file
@@ -0,0 +1,62 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Pages.TreeComboBoxDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:TreeComboBoxDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel>
|
||||
<u:TreeComboBox Width="300" HorizontalAlignment="Left">
|
||||
<u:TreeComboBoxItem Header="Hello">
|
||||
<u:TreeComboBoxItem Header="Hello World">
|
||||
<u:TreeComboBoxItem Header="Hello World 1" />
|
||||
<u:TreeComboBoxItem Header="Hello World 2" />
|
||||
<u:TreeComboBoxItem Header="Hello World 3" />
|
||||
</u:TreeComboBoxItem>
|
||||
<u:TreeComboBoxItem Header="Hello Avalonia" />
|
||||
<u:TreeComboBoxItem Header="Hello Another" />
|
||||
</u:TreeComboBoxItem>
|
||||
<u:TreeComboBoxItem Header="World">
|
||||
<u:TreeComboBoxItem Header="World Hello" />
|
||||
<u:TreeComboBoxItem Header="World Avalonia" />
|
||||
<u:TreeComboBoxItem Header="World Another" />
|
||||
</u:TreeComboBoxItem>
|
||||
</u:TreeComboBox>
|
||||
<u:TreeComboBox
|
||||
Width="300"
|
||||
Watermark="Please select an item. "
|
||||
HorizontalAlignment="Left"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
ItemsSource="{Binding Items}">
|
||||
<u:TreeComboBox.ItemTemplate>
|
||||
<TreeDataTemplate ItemsSource="{Binding Children}">
|
||||
<TextBlock Text="{Binding ItemName}" />
|
||||
</TreeDataTemplate>
|
||||
</u:TreeComboBox.ItemTemplate>
|
||||
</u:TreeComboBox>
|
||||
|
||||
<u:TreeComboBox
|
||||
Classes="clearButton"
|
||||
Width="300"
|
||||
Watermark="Please select an item. "
|
||||
HorizontalAlignment="Left"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
InnerRightContent="Right"
|
||||
InnerLeftContent="Left"
|
||||
PopupInnerTopContent="Top"
|
||||
PopupInnerBottomContent="Bottom"
|
||||
ItemsSource="{Binding Items}">
|
||||
<u:TreeComboBox.ItemTemplate>
|
||||
<TreeDataTemplate ItemsSource="{Binding Children}">
|
||||
<TextBlock Text="{Binding ItemName}" />
|
||||
</TreeDataTemplate>
|
||||
</u:TreeComboBox.ItemTemplate>
|
||||
</u:TreeComboBox>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/TreeComboBoxDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class TreeComboBoxDemo : UserControl
|
||||
{
|
||||
public TreeComboBoxDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class MainViewViewModel : ViewModelBase
|
||||
MenuKeys.MenuKeySkeleton => new SkeletonDemoViewModel(),
|
||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
||||
MenuKeys.MenuKeyTreeComboBox => new TreeComboBoxDemoViewModel(),
|
||||
MenuKeys.MenuKeyTwoTonePathIcon => new TwoTonePathIconDemoViewModel(),
|
||||
MenuKeys.MenuKeyThemeToggler => new ThemeTogglerDemoViewModel(),
|
||||
MenuKeys.MenuKeyToolBar => new ToolBarDemoViewModel(),
|
||||
|
||||
@@ -44,6 +44,7 @@ public class MenuViewModel: ViewModelBase
|
||||
new() { MenuHeader = "TagInput", Key = MenuKeys.MenuKeyTagInput },
|
||||
new() { MenuHeader = "Theme Toggler", Key = MenuKeys.MenuKeyThemeToggler },
|
||||
new() { MenuHeader = "Timeline", Key = MenuKeys.MenuKeyTimeline },
|
||||
new() { MenuHeader = "TreeComboBox", Key = MenuKeys.MenuKeyTreeComboBox },
|
||||
new() { MenuHeader = "TwoTonePathIcon", Key = MenuKeys.MenuKeyTwoTonePathIcon},
|
||||
new() { MenuHeader = "ToolBar", Key = MenuKeys.MenuKeyToolBar },
|
||||
new() { MenuHeader = "Time Box", Key = MenuKeys.MenuKeyTimeBox, Status = "New" },
|
||||
@@ -88,6 +89,7 @@ public static class MenuKeys
|
||||
public const string MenuKeyTimeline = "Timeline";
|
||||
public const string MenuKeyTwoTonePathIcon = "TwoTonePathIcon";
|
||||
public const string MenuKeyThemeToggler = "ThemeToggler";
|
||||
public const string MenuKeyTreeComboBox = "TreeComboBox";
|
||||
public const string MenuKeyToolBar = "ToolBar";
|
||||
public const string MenuKeyVerificationCode = "VerificationCode";
|
||||
public const string MenuKeyTimeBox = "TimeBox";
|
||||
|
||||
68
demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs
Normal file
68
demo/Ursa.Demo/ViewModels/TreeComboBoxDemoViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public partial class TreeComboBoxDemoViewModel: ObservableObject
|
||||
{
|
||||
[ObservableProperty] private TreeComboBoxItemViewModel? _selectedItem;
|
||||
public List<TreeComboBoxItemViewModel> Items { get; set; }
|
||||
|
||||
public TreeComboBoxDemoViewModel()
|
||||
{
|
||||
Items = new List<TreeComboBoxItemViewModel>()
|
||||
{
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 1",
|
||||
Children = new List<TreeComboBoxItemViewModel>()
|
||||
{
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 1-1",
|
||||
Children = new List<TreeComboBoxItemViewModel>()
|
||||
{
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 1-1-1"
|
||||
},
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 1-1-2"
|
||||
}
|
||||
}
|
||||
},
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 1-2"
|
||||
}
|
||||
}
|
||||
},
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 2",
|
||||
Children = new List<TreeComboBoxItemViewModel>()
|
||||
{
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 2-1"
|
||||
},
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 2-2"
|
||||
}
|
||||
}
|
||||
},
|
||||
new TreeComboBoxItemViewModel()
|
||||
{
|
||||
ItemName = "Item 3"
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TreeComboBoxItemViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private string? _itemName;
|
||||
public List<TreeComboBoxItemViewModel> Children { get; set; } = new ();
|
||||
}
|
||||
Reference in New Issue
Block a user