docs-maui
docs-maui copied to clipboard
Navigation Issue
Type of issue
Code doesn't work
Description
Downloaded the following code: https://github.com/dotnet/maui-samples/tree/main/8.0/UserInterface/Layouts/AbsoluteLayoutDemos The menu on the MainPage does not work under Windows emulator. When app opens, I can click on a menu item and navigate to a page. When I return to the menu I cannot navigate to anymore pages. Menu DOES work under Android emulator as expected. Asked Copilot and the last suggestion which didn't work, is included below:
`using System.Diagnostics; using System.Windows.Input;
namespace AbsoluteLayoutDemos { public partial class MainPage : ContentPage { public ICommand NavigateCommand { get; private set; }
public MainPage()
{
InitializeComponent();
Debug.WriteLine("MainPage constructor called");
NavigateCommand = new Command<Type>(
async (Type pageType) =>
{
Debug.WriteLine($"Navigating to {pageType.Name}");
Page page = (Page)Activator.CreateInstance(pageType);
await Navigation.PushAsync(page);
Debug.WriteLine($"Navigation stack count: {Navigation.NavigationStack.Count}");
});
BindingContext = this;
}
protected override void OnAppearing()
{
base.OnAppearing();
Debug.WriteLine("MainPage appeared");
BindingContext = this; // Ensure BindingContext is set
}
protected override void OnDisappearing()
{
base.OnDisappearing();
Debug.WriteLine("MainPage disappeared");
}
}
} ` I noticed other samples didn't work as well.
P.S. Couldn't figure out how to insert a link correctly. Have to copy text and paste. Please fix this issue as well or post instructions on different options available such as what does a slash command do.
[Enter feedback here]
Page URL
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/layouts/absolutelayout?view=net-maui-8.0
Content source URL
https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/layouts/absolutelayout.md
Document Version Independent Id
d8aac004-9823-8211-3e9d-aefe7d9c4d95
Article author
@davidbritch
Metadata
- ID: d8aac004-9823-8211-3e9d-aefe7d9c4d95
- Service: dotnet-mobile
- Sub-service: dotnet-maui