From 38958c13263e4b273d3fccaf2c74e21cfcb15f22 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Thu, 28 Mar 2024 05:17:59 +0800 Subject: [PATCH] feat: redesign SplitViewDemo. --- .../Pages/SplitViewDemo.axaml | 283 ++++++++++-------- .../Pages/SplitViewDemo.axaml.cs | 28 +- .../ViewModels/DataGridDemoViewModel.cs | 2 +- 3 files changed, 192 insertions(+), 121 deletions(-) diff --git a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml index b63b60c..7de95ef 100644 --- a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml +++ b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml @@ -4,149 +4,194 @@ 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" - d:DesignHeight="450" + xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages" + d:DesignHeight="1000" d:DesignWidth="800" mc:Ignorable="d"> + + + + + + M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z + + - - + + + - - + + + + CompactPaneLength="48" + OpenPaneLength="256"> + + + + + + - + - - - - - - + + - - - - - - - - - - - - - + Theme="{DynamicResource ButtonToggleSwitch}" + IsChecked="{Binding #SplitView.IsPaneOpen}"> + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml.cs index e8a834f..2fb52a5 100644 --- a/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml.cs +++ b/demo/Semi.Avalonia.Demo/Pages/SplitViewDemo.axaml.cs @@ -1,6 +1,7 @@ -using Avalonia; +using System.Collections.ObjectModel; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using CommunityToolkit.Mvvm.ComponentModel; namespace Semi.Avalonia.Demo.Pages; @@ -9,10 +10,35 @@ public partial class SplitViewDemo : UserControl public SplitViewDemo() { InitializeComponent(); + this.DataContext = new SplitViewDemoViewModel(); } private void InitializeComponent() { AvaloniaXamlLoader.Load(this); } +} + +public class SplitViewDemoViewModel : ObservableObject +{ + public ObservableCollection Songs { get; set; } = + [ + "320万年前", + "隐德来希", + "孔明", + "锦鲤卟噜噜", + "指鹿为马", + "热带季风Remix", + "加州梦境", + "渐近自由", + "世界所有的烂漫", + ]; + + public ObservableCollection DisplayModes { get; set; } = + [ + SplitViewDisplayMode.Inline, + SplitViewDisplayMode.CompactInline, + SplitViewDisplayMode.Overlay, + SplitViewDisplayMode.CompactOverlay, + ]; } \ No newline at end of file diff --git a/demo/Semi.Avalonia.Demo/ViewModels/DataGridDemoViewModel.cs b/demo/Semi.Avalonia.Demo/ViewModels/DataGridDemoViewModel.cs index bb8fa4b..43ecbf0 100644 --- a/demo/Semi.Avalonia.Demo/ViewModels/DataGridDemoViewModel.cs +++ b/demo/Semi.Avalonia.Demo/ViewModels/DataGridDemoViewModel.cs @@ -121,7 +121,7 @@ public class Song new("指鹿为马", "熊猫堂ProducePandas", 3, 12, "W.O.R.L.D.", 74, 2063175272), new("热带季风Remix", "熊猫堂ProducePandas", 3, 22, "W.O.R.L.D.", 23, 2063173319), new("加州梦境", "熊猫堂ProducePandas", 2, 56, "W.O.R.L.D.", 1662, 2063173324), - new("渐进自由", "熊猫堂ProducePandas", 4, 19, "W.O.R.L.D.", 124, 2063173321), + new("渐近自由", "熊猫堂ProducePandas", 4, 19, "W.O.R.L.D.", 124, 2063173321), new("世界所有的烂漫", "熊猫堂ProducePandas", 3, 30, "W.O.R.L.D.", 335, 2053388775), }; }