From 331141197d458ae0e846b19c453314f1c5f69f6e Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Thu, 30 Apr 2026 14:53:38 +0800
Subject: [PATCH] Enhance DrawerPage (#813)
* feat: enhance navigation and UI structure in MainView and Application.
* fix: using ContentPreseter and add HeaderTemplate.
* feat: add locale resource for navigation drawer toggle button text.
* feat: add customizations for DrawerPageDemo.
* fix: fix DrawerPage title vertical alignment to Center.
* Update DrawerPageDemo.axaml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update DrawerPageDemo.axaml.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix: fix bottom bar styles.
* fix: update border background color in DrawerPageDemo.axaml.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
.../Pages/DrawerPageDemo.axaml | 93 +++++++++++-----
.../Pages/DrawerPageDemo.axaml.cs | 49 +--------
src/Semi.Avalonia/Controls/DrawerPage.axaml | 100 ++++++++----------
src/Semi.Avalonia/Locale/de-de.axaml | 4 +-
src/Semi.Avalonia/Locale/en-gb.axaml | 4 +-
src/Semi.Avalonia/Locale/en-us.axaml | 4 +-
src/Semi.Avalonia/Locale/es-es.axaml | 4 +-
src/Semi.Avalonia/Locale/fr-fr.axaml | 2 +
src/Semi.Avalonia/Locale/it-ch.axaml | 4 +-
src/Semi.Avalonia/Locale/it-it.axaml | 4 +-
src/Semi.Avalonia/Locale/ja-jp.axaml | 4 +-
src/Semi.Avalonia/Locale/ko-kr.axaml | 4 +-
src/Semi.Avalonia/Locale/nl-be.axaml | 4 +-
src/Semi.Avalonia/Locale/nl-nl.axaml | 4 +-
src/Semi.Avalonia/Locale/pl-pl.axaml | 4 +-
src/Semi.Avalonia/Locale/ru-ru.axaml | 4 +-
src/Semi.Avalonia/Locale/uk-ua.axaml | 4 +-
src/Semi.Avalonia/Locale/zh-cn.axaml | 4 +-
src/Semi.Avalonia/Locale/zh-tw.axaml | 4 +-
.../Themes/Light/DrawerPage.axaml | 2 +-
.../Themes/Shared/DrawerPage.axaml | 4 +
21 files changed, 162 insertions(+), 148 deletions(-)
diff --git a/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml b/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml
index 0636b90..f5ea1a4 100644
--- a/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml
+++ b/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml
@@ -10,45 +10,84 @@
-
+
-
-
-
+
-
-
-
-
-
-
+ IsChecked="True" />
+
+
+
+ Auto
+ Flyout
+ Locked
+ Disabled
-
+
+
+ Overlay
+ Split
+ CompactOverlay
+ CompactInline
+
-
-
+
+
+ Left
+ Right
+ Top
+ Bottom
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+ IsOpen="{Binding #ToggleDrawerCheck.IsChecked}"
+ IsGestureEnabled="{Binding #GestureCheck.IsChecked}"
+ DrawerBehavior="{Binding #BehaviorComboBox.SelectedItem}"
+ DrawerLayoutBehavior="{Binding #LayoutComboBox.SelectedItem}"
+ DrawerPlacement="{Binding #PlacementComboBox.SelectedItem}"
+ CompactDrawerLength="{Binding #CompactDrawerLengthSlider.Value}"
+ DrawerLength="{Binding #DrawerLengthSlider.Value}">
@@ -74,4 +113,4 @@
-
\ No newline at end of file
+
diff --git a/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml.cs b/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml.cs
index 4428e53..17a1dae 100644
--- a/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml.cs
+++ b/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Linq;
+using System.Linq;
using Avalonia.Controls;
using Avalonia.Input.GestureRecognizers;
-using Avalonia.Interactivity;
using Avalonia.Layout;
namespace Semi.Avalonia.Demo.Pages;
@@ -15,32 +13,6 @@ public partial class DrawerPageDemo : UserControl
EnableMouseSwipeGesture(DemoDrawer);
}
- protected override void OnLoaded(RoutedEventArgs e)
- {
- base.OnLoaded(e);
- DemoDrawer.Opened += OnDrawerStatusChanged;
- DemoDrawer.Closed += OnDrawerStatusChanged;
- }
-
- protected override void OnUnloaded(RoutedEventArgs e)
- {
- base.OnUnloaded(e);
- DemoDrawer.Opened -= OnDrawerStatusChanged;
- DemoDrawer.Closed -= OnDrawerStatusChanged;
- }
-
- private void OnDrawerStatusChanged(object? sender, EventArgs e) => UpdateStatus();
-
- private void OnToggleDrawer(object? sender, RoutedEventArgs e)
- {
- DemoDrawer.IsOpen = !DemoDrawer.IsOpen;
- }
-
- private void OnGestureChanged(object? sender, RoutedEventArgs e)
- {
- DemoDrawer.IsGestureEnabled = GestureCheck.IsChecked == true;
- }
-
private void OnMenuSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (DrawerMenu.SelectedItem is ListBoxItem item)
@@ -62,11 +34,6 @@ public partial class DrawerPageDemo : UserControl
}
}
- private void UpdateStatus()
- {
- StatusText.Text = $"Drawer: {(DemoDrawer.IsOpen ? "Open" : "Closed")}";
- }
-
private static void EnableMouseSwipeGesture(Control control)
{
var recognizer = control.GestureRecognizers
@@ -75,16 +42,4 @@ public partial class DrawerPageDemo : UserControl
recognizer?.IsMouseEnabled = true;
}
-
- private void OnLayoutChanged(object? sender, SelectionChangedEventArgs e)
- {
- DemoDrawer.DrawerLayoutBehavior = (sender as ComboBox)?.SelectedIndex switch
- {
- 0 => DrawerLayoutBehavior.CompactOverlay,
- 1 => DrawerLayoutBehavior.CompactInline,
- 2 => DrawerLayoutBehavior.Split,
- 3 => DrawerLayoutBehavior.Overlay,
- _ => DrawerLayoutBehavior.CompactOverlay
- };
- }
-}
\ No newline at end of file
+}
diff --git a/src/Semi.Avalonia/Controls/DrawerPage.axaml b/src/Semi.Avalonia/Controls/DrawerPage.axaml
index 556a7e2..c6ffced 100644
--- a/src/Semi.Avalonia/Controls/DrawerPage.axaml
+++ b/src/Semi.Avalonia/Controls/DrawerPage.axaml
@@ -20,27 +20,23 @@
+ IsVisible="False">
+ IsVisible="{TemplateBinding DrawerHeader, Converter={x:Static ObjectConverters.IsNotNull}}" />
+ IsVisible="{TemplateBinding DrawerFooter, Converter={x:Static ObjectConverters.IsNotNull}}" />
-
+
-
+ Background="{DynamicResource DrawerPageTopBarBackground}">
+
+ IsChecked="{Binding #PART_SplitView.IsPaneOpen, Mode=TwoWay}">
-
+ ContentTemplate="{TemplateBinding HeaderTemplate}"
+ FontSize="{DynamicResource DrawerPageTitleFontSize}"
+ FontWeight="{DynamicResource DrawerPageTitleFontWeight}"
+ IsVisible="{TemplateBinding Header, Converter={x:Static ObjectConverters.IsNotNull}}" />
-
+
+ AutomationProperties.Name="Toggle navigation drawer"
+ ToolTip.Tip="{DynamicResource STRING_DRAWERPAGE_TOGGLE_NAVIGATION_DRAWER}"
+ Width="{DynamicResource ButtonDefaultHeight}"
+ Height="{DynamicResource ButtonDefaultHeight}"
+ Background="Transparent"
+ IsChecked="{Binding #PART_SplitView.IsPaneOpen, Mode=TwoWay}">
-
+ ContentTemplate="{TemplateBinding HeaderTemplate}"
+ FontSize="{DynamicResource DrawerPageTitleFontSize}"
+ FontWeight="{DynamicResource DrawerPageTitleFontWeight}"
+ IsVisible="{TemplateBinding Header, Converter={x:Static ObjectConverters.IsNotNull}}" />
-
+
@@ -249,4 +233,4 @@
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/de-de.axaml b/src/Semi.Avalonia/Locale/de-de.axaml
index ebb4b3e..d4d70de 100644
--- a/src/Semi.Avalonia/Locale/de-de.axaml
+++ b/src/Semi.Avalonia/Locale/de-de.axaml
@@ -14,6 +14,8 @@
Ausschneiden
Kopieren
Einfügen
+
+ Navigationsleiste umschalten
Dateiname
Ausgeblendete Elemente anzeigen
@@ -24,4 +26,4 @@
Typ
Größe
Die Datei {0} existiert bereits. Möchten Sie sie ersetzen?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/en-gb.axaml b/src/Semi.Avalonia/Locale/en-gb.axaml
index fb01705..5ebfb77 100644
--- a/src/Semi.Avalonia/Locale/en-gb.axaml
+++ b/src/Semi.Avalonia/Locale/en-gb.axaml
@@ -14,6 +14,8 @@
Cut
Copy
Paste
+
+ Toggle navigation drawer
File name
Show hidden files
@@ -24,4 +26,4 @@
Type
Size
{0} already exists. Do you want to replace it?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/en-us.axaml b/src/Semi.Avalonia/Locale/en-us.axaml
index 8d7d9ba..359770e 100644
--- a/src/Semi.Avalonia/Locale/en-us.axaml
+++ b/src/Semi.Avalonia/Locale/en-us.axaml
@@ -14,6 +14,8 @@
Cut
Copy
Paste
+
+ Toggle navigation drawer
File name
Show hidden files
@@ -24,4 +26,4 @@
Type
Size
{0} already exists. Do you want to replace it?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/es-es.axaml b/src/Semi.Avalonia/Locale/es-es.axaml
index 16367f7..fd6d3cf 100644
--- a/src/Semi.Avalonia/Locale/es-es.axaml
+++ b/src/Semi.Avalonia/Locale/es-es.axaml
@@ -14,6 +14,8 @@
Cortar
Copiar
Pegar
+
+ Alternar panel de navegación
Nombre de fichero
Mostrar ficheros ocultos
@@ -24,4 +26,4 @@
Tipo
Tamaño
{0} ya existe. Quieres reemplazarlo?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/fr-fr.axaml b/src/Semi.Avalonia/Locale/fr-fr.axaml
index 5a3b207..87c744b 100644
--- a/src/Semi.Avalonia/Locale/fr-fr.axaml
+++ b/src/Semi.Avalonia/Locale/fr-fr.axaml
@@ -14,6 +14,8 @@
Couper
Copier
Coller
+
+ Basculer le volet de navigation
Nom du fichier
Afficher les fichiers cachés
diff --git a/src/Semi.Avalonia/Locale/it-ch.axaml b/src/Semi.Avalonia/Locale/it-ch.axaml
index cedcb1b..d93efa3 100644
--- a/src/Semi.Avalonia/Locale/it-ch.axaml
+++ b/src/Semi.Avalonia/Locale/it-ch.axaml
@@ -14,6 +14,8 @@
Taglia
Copia
Incolla
+
+ Attiva/disattiva riquadro di navigazione
Nome file
Mostra file nascosti
@@ -24,4 +26,4 @@
Tipo
Dimensione
{0} è già esistente. Sovrascriverlo?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/it-it.axaml b/src/Semi.Avalonia/Locale/it-it.axaml
index dc7ef63..6a4a9bf 100644
--- a/src/Semi.Avalonia/Locale/it-it.axaml
+++ b/src/Semi.Avalonia/Locale/it-it.axaml
@@ -14,6 +14,8 @@
Taglia
Copia
Incolla
+
+ Attiva/disattiva riquadro di navigazione
Nome file
Mostra file nascosti
@@ -24,4 +26,4 @@
Tipo
Dimensione
{0} è già esistente. Sovrascriverlo?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/ja-jp.axaml b/src/Semi.Avalonia/Locale/ja-jp.axaml
index c9dbd6b..1f14ff5 100644
--- a/src/Semi.Avalonia/Locale/ja-jp.axaml
+++ b/src/Semi.Avalonia/Locale/ja-jp.axaml
@@ -14,6 +14,8 @@
切り取り
コピー
貼り付け
+
+ ナビゲーション ドロワーを切り替える
ファイル名
隠しファイルを表示
@@ -24,4 +26,4 @@
種類
サイズ
{0} はすでに存在します。置き換えますか?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/ko-kr.axaml b/src/Semi.Avalonia/Locale/ko-kr.axaml
index 2592013..e288ab6 100644
--- a/src/Semi.Avalonia/Locale/ko-kr.axaml
+++ b/src/Semi.Avalonia/Locale/ko-kr.axaml
@@ -14,6 +14,8 @@
잘라내기
복사
붙여넣기
+
+ 탐색 창 전환
파일 이름
숨긴 파일 표시
@@ -24,4 +26,4 @@
유형
크기
{0}이(가) 이미 있습니다. 바꾸시겠습니까?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/nl-be.axaml b/src/Semi.Avalonia/Locale/nl-be.axaml
index 2eed872..9106f63 100644
--- a/src/Semi.Avalonia/Locale/nl-be.axaml
+++ b/src/Semi.Avalonia/Locale/nl-be.axaml
@@ -14,6 +14,8 @@
Knippen
Kopiëren
Plakken
+
+ Navigatievenster openen of sluiten
Bestandsnaam
Toon verborgen bestanden
@@ -24,4 +26,4 @@
Type
Grootte
{0} bestaat al. Wilt u het vervangen?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/nl-nl.axaml b/src/Semi.Avalonia/Locale/nl-nl.axaml
index 1ff8571..863836d 100644
--- a/src/Semi.Avalonia/Locale/nl-nl.axaml
+++ b/src/Semi.Avalonia/Locale/nl-nl.axaml
@@ -14,6 +14,8 @@
Knippen
Kopiëren
Plakken
+
+ Navigatievenster openen of sluiten
Bestandsnaam
Toon verborgen bestanden
@@ -24,4 +26,4 @@
Type
Grootte
{0} bestaat al. Wilt u het vervangen?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/pl-pl.axaml b/src/Semi.Avalonia/Locale/pl-pl.axaml
index 57310c5..b152bef 100644
--- a/src/Semi.Avalonia/Locale/pl-pl.axaml
+++ b/src/Semi.Avalonia/Locale/pl-pl.axaml
@@ -14,6 +14,8 @@
Wytnij
Kopiuj
Wklej
+
+ Przełącz panel nawigacyjny
Nazwa pliku
Pokaż ukryte pliki
@@ -24,4 +26,4 @@
Typ
Rozmiar
{0} już istnieje. Czy zamienić istniejący plik?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/ru-ru.axaml b/src/Semi.Avalonia/Locale/ru-ru.axaml
index b6388f8..1f6fcd1 100644
--- a/src/Semi.Avalonia/Locale/ru-ru.axaml
+++ b/src/Semi.Avalonia/Locale/ru-ru.axaml
@@ -14,6 +14,8 @@
Вырезать
Копировать
Вставить
+
+ Переключить панель навигации
Имя файла
Показать скрытые файлы
@@ -24,4 +26,4 @@
Тип
Размер
{0} уже существует. Вы хотите заменить его?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/uk-ua.axaml b/src/Semi.Avalonia/Locale/uk-ua.axaml
index b1cd2e5..ea2ed24 100644
--- a/src/Semi.Avalonia/Locale/uk-ua.axaml
+++ b/src/Semi.Avalonia/Locale/uk-ua.axaml
@@ -14,6 +14,8 @@
Вирізати
Копіювати
Вставити
+
+ Перемкнути панель навігації
Ім'я файлу
Показати приховані папки
@@ -24,4 +26,4 @@
Тип
Розмір
{0} уже існує. Ви бажаєте замінити його?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/zh-cn.axaml b/src/Semi.Avalonia/Locale/zh-cn.axaml
index e2489ab..32127c5 100644
--- a/src/Semi.Avalonia/Locale/zh-cn.axaml
+++ b/src/Semi.Avalonia/Locale/zh-cn.axaml
@@ -14,6 +14,8 @@
剪切
复制
粘贴
+
+ 切换导航抽屉
文件名
显示隐藏文件
@@ -24,4 +26,4 @@
类型
大小
{0} 已经存在。您要替换它吗?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Locale/zh-tw.axaml b/src/Semi.Avalonia/Locale/zh-tw.axaml
index dd1c99c..3f80fe4 100644
--- a/src/Semi.Avalonia/Locale/zh-tw.axaml
+++ b/src/Semi.Avalonia/Locale/zh-tw.axaml
@@ -14,6 +14,8 @@
剪下
複製
貼上
+
+ 切換導覽抽屜
檔案名
顯示隱藏檔案
@@ -24,4 +26,4 @@
類型
大小
{0} 已經存在。您要取代它嗎?
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Themes/Light/DrawerPage.axaml b/src/Semi.Avalonia/Themes/Light/DrawerPage.axaml
index 518a63f..1a5dc4a 100644
--- a/src/Semi.Avalonia/Themes/Light/DrawerPage.axaml
+++ b/src/Semi.Avalonia/Themes/Light/DrawerPage.axaml
@@ -6,4 +6,4 @@
-
\ No newline at end of file
+
diff --git a/src/Semi.Avalonia/Themes/Shared/DrawerPage.axaml b/src/Semi.Avalonia/Themes/Shared/DrawerPage.axaml
index e637290..0dc29cc 100644
--- a/src/Semi.Avalonia/Themes/Shared/DrawerPage.axaml
+++ b/src/Semi.Avalonia/Themes/Shared/DrawerPage.axaml
@@ -4,4 +4,8 @@
+
+
+
+ 8 0 0 0