diff --git a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml
similarity index 80%
rename from demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml
rename to demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml
index 0928a67..ef965c6 100644
--- a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml
+++ b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml
@@ -1,5 +1,5 @@
diff --git a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs
similarity index 71%
rename from demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs
rename to demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs
index c317cf5..b3f1927 100644
--- a/demo/Semi.Avalonia.Demo/Pages/GridSplitter.axaml.cs
+++ b/demo/Semi.Avalonia.Demo/Pages/GridSplitterDemo.axaml.cs
@@ -1,12 +1,11 @@
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Semi.Avalonia.Demo.Pages;
-public partial class GridSplitter : UserControl
+public partial class GridSplitterDemo : UserControl
{
- public GridSplitter()
+ public GridSplitterDemo()
{
InitializeComponent();
}
diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml b/demo/Semi.Avalonia.Demo/Views/MainView.axaml
index 0c12b22..28ff0a8 100644
--- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml
+++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml
@@ -42,29 +42,67 @@
Text="{ReflectionBinding #tab.SelectedItem.Header}" />
-
-
-
+
@@ -209,4 +247,4 @@
-
+
\ No newline at end of file
diff --git a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs
index 3799536..d3e3d97 100644
--- a/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs
+++ b/demo/Semi.Avalonia.Demo/Views/MainView.axaml.cs
@@ -1,10 +1,12 @@
using System;
-using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Styling;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
namespace Semi.Avalonia.Demo.Views;
@@ -45,32 +47,61 @@ public partial class MainView : UserControl
public partial class MainViewModel : ObservableObject
{
- public ObservableCollection Themes { get; } =
- [
- new("Default", ThemeVariant.Default),
- new("Light", ThemeVariant.Light),
- new("Dark", ThemeVariant.Dark),
- new("Aquatic", SemiTheme.Aquatic),
- new("Desert", SemiTheme.Desert),
- new("Dust", SemiTheme.Dust),
- new("NightSky", SemiTheme.NightSky)
- ];
+ public IReadOnlyList MenuItems { get; }
- [ObservableProperty] private ThemeItem? _selectedTheme;
-
- partial void OnSelectedThemeChanged(ThemeItem? oldValue, ThemeItem? newValue)
+ public MainViewModel()
+ {
+ MenuItems =
+ [
+ new MenuItemViewModel
+ {
+ Header = "High Contrast Theme",
+ Items =
+ [
+ new MenuItemViewModel
+ {
+ Header = "Aquatic",
+ Command = SelectThemeCommand,
+ CommandParameter = SemiTheme.Aquatic
+ },
+ new MenuItemViewModel
+ {
+ Header = "Desert",
+ Command = SelectThemeCommand,
+ CommandParameter = SemiTheme.Desert
+ },
+ new MenuItemViewModel
+ {
+ Header = "Dust",
+ Command = SelectThemeCommand,
+ CommandParameter = SemiTheme.Dust
+ },
+ new MenuItemViewModel
+ {
+ Header = "NightSky",
+ Command = SelectThemeCommand,
+ CommandParameter = SemiTheme.NightSky
+ },
+ ]
+ }
+ ];
+ }
+
+ [RelayCommand]
+ public void SelectTheme(object? obj)
{
- if (newValue is null) return;
var app = Application.Current;
if (app is not null)
{
- app.RequestedThemeVariant = newValue.Theme;
+ app.RequestedThemeVariant = obj as ThemeVariant;
}
}
}
-public class ThemeItem(string name, ThemeVariant theme)
+public class MenuItemViewModel
{
- public string Name { get; set; } = name;
- public ThemeVariant Theme { get; set; } = theme;
+ public string? Header { get; set; }
+ public ICommand? Command { get; set; }
+ public object? CommandParameter { get; set; }
+ public IList? Items { get; set; }
}
\ No newline at end of file