postit: change MainPage base class from NavigationPage to ContentPage

HomePage.OnLoginClick does Navigation.PushAsync(new MainPage
{ ... }). NavigationPage.PushAsync only accepts a Page (or
Page subclass), not a MultiPage. MainPage was declared as

  public partial class MainPage : NavigationPage

in MainPage.axaml.cs and the root of MainPage.axaml was

  <NavigationPage ...>

which means 'new MainPage()' produced a MultiPage, not a
Page. PushAsync against a MultiPage argument does not route
through the standard Page push path; the visible result is
that the login succeeds, LoginSucceeded fires, but the UI
stays on LoginPage — the user is left looking at the
post-login state without any navigation.

The XAML content of MainPage (a StackPanel with the post
CRUD UI, a ListBox, a TextEditor) does not need the
multi-page container semantics — it's a single screen.
Switch both the code-behind base class and the XAML root
element to ContentPage so that MainPage is what
PushAsync expects.
This commit is contained in:
Paul Schneider 2026-06-28 01:13:08 +01:00
commit fd6d6ab2d8
2 changed files with 4 additions and 5 deletions

View file

@ -1,4 +1,4 @@
<NavigationPage xmlns="https://github.com/avaloniaui"
<ContentPage xmlns="https://github.com/avaloniaui"
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"
@ -57,4 +57,4 @@
</Border>
</StackPanel>
</NavigationPage>
</ContentPage>

View file

@ -1,14 +1,13 @@
using Avalonia;
using Avalonia.Controls;
namespace PostIt.Views;
public partial class MainPage : NavigationPage
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
}