Files
Semi.Avalonia/demo/Semi.Avalonia.Demo/Pages/NavigationPageDemo.axaml.cs
Copilot 1d59cff87d Implement Semi Design theme for page-based navigation controls (ContentPage / DrawerPage / NavigationPage / TabbedPage) (#766)
* Initial plan

* Implement Semi Design theme for ContentPage, DrawerPage, NavigationPage, TabbedPage

Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com>

* fix: bind ItemsSource to Pages in TabControl of TabbedPage.

* chore: split demo navigation pages.

* demo: improve NavigationPage demo pages with interactive controls

Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com>

* fix: use comma-separated Padding syntax and remove trailing newline

Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com>

* feat: implement semi design theme for navigation controls in demo pages.

* feat: enhance demo pages with foreground color for better visibility

* feat: add back button visibility control and improve navigation page layout.

* chore: remove DrawerPage unused static resources.

* feat: add HighContrast resources for ContentPage, DrawerPage, NavigationPage, TabbedPage

Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com>

* feat: implement CardTabbedPage & ButtonTabbedPage themes.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com>
Co-authored-by: Dong Bin <popmessiah@hotmail.com>
2026-03-15 03:37:50 +08:00

66 lines
2.0 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
namespace Semi.Avalonia.Demo.Pages;
public partial class NavigationPageDemo : UserControl
{
private int _pageCount;
public NavigationPageDemo()
{
InitializeComponent();
Loaded += OnLoaded;
}
private async void OnLoaded(object? sender, RoutedEventArgs e)
{
await DemoNav.PushAsync(NavigationDemoHelper.MakePage("Home", "Welcome!\nUse the buttons to push and pop pages.", 0), null);
UpdateStatus();
}
private async void OnPush(object? sender, RoutedEventArgs e)
{
_pageCount++;
var page = NavigationDemoHelper.MakePage($"Page {_pageCount}", $"This is page {_pageCount}.", _pageCount);
NavigationPage.SetHasNavigationBar(page, HasNavBarCheck.IsChecked == true);
NavigationPage.SetHasBackButton(page, HasBackButtonCheck.IsChecked == true);
await DemoNav.PushAsync(page);
UpdateStatus();
}
private async void OnPop(object? sender, RoutedEventArgs e)
{
await DemoNav.PopAsync();
UpdateStatus();
}
private async void OnPopToRoot(object? sender, RoutedEventArgs e)
{
await DemoNav.PopToRootAsync();
_pageCount = 0;
UpdateStatus();
}
private void OnHasNavBarChanged(object? sender, RoutedEventArgs e)
{
if (DemoNav == null)
return;
if (DemoNav.CurrentPage != null)
NavigationPage.SetHasNavigationBar(DemoNav.CurrentPage, HasNavBarCheck.IsChecked == true);
}
private void OnHasBackButonChanged(object? sender, RoutedEventArgs e)
{
if (DemoNav == null)
return;
if (DemoNav.CurrentPage != null)
NavigationPage.SetHasBackButton(DemoNav.CurrentPage, HasBackButtonCheck.IsChecked == true);
}
private void UpdateStatus()
{
StatusText.Text = $"Depth: {DemoNav.StackDepth}";
HeaderText.Text = $"Current: {DemoNav.CurrentPage?.Header ?? "(none)"}";
}
}