Files
Semi.Avalonia/demo/Semi.Avalonia.Demo/Pages/DrawerPageDemo.axaml.cs
Zhang Dian 331141197d 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>
2026-04-30 14:53:38 +08:00

46 lines
1.3 KiB
C#

using System.Linq;
using Avalonia.Controls;
using Avalonia.Input.GestureRecognizers;
using Avalonia.Layout;
namespace Semi.Avalonia.Demo.Pages;
public partial class DrawerPageDemo : UserControl
{
public DrawerPageDemo()
{
InitializeComponent();
EnableMouseSwipeGesture(DemoDrawer);
}
private void OnMenuSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (DrawerMenu.SelectedItem is ListBoxItem item)
{
DemoDrawer.Content = new ContentPage
{
Header = item.Content?.ToString(),
Content = new TextBlock
{
Text = $"{item.Content} page content",
FontSize = 16,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
HorizontalContentAlignment = HorizontalAlignment.Stretch,
VerticalContentAlignment = VerticalAlignment.Stretch
};
DemoDrawer.IsOpen = false;
}
}
private static void EnableMouseSwipeGesture(Control control)
{
var recognizer = control.GestureRecognizers
.OfType<SwipeGestureRecognizer>()
.FirstOrDefault();
recognizer?.IsMouseEnabled = true;
}
}