Reputation: 2898
I'm at a loss of what I could be encountering. I've got two things going on that could be related but I want to figure out this issue as it may be the cause of the second issue.
My appshell is pretty basic:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Manager.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Manager"
xmlns:pages="clr-namespace:Manager.Pages"
Shell.FlyoutBehavior="Flyout">
<Shell.FlyoutHeaderTemplate>
<DataTemplate>
<Grid BackgroundColor="DimGray">
<Label>Configuration</Label>
</Grid>
</DataTemplate>
</Shell.FlyoutHeaderTemplate>
<ShellContent
Title="Manager"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
<ShellContent
Title="add item"
ContentTemplate="{DataTemplate pages:AddItemPage}"
Route="pages:AddItemPage" />
<ShellContent
Title="check Items"
ContentTemplate="{DataTemplate pages:CheckItemPage}"
Route="pages:CheckItemPage" />
</Shell>
I had other pages listed there prior and switched them out to see if they were having issues. The "second" issue I was encountering is if I navigate onto one of the pages then back again, the app crashes with: System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'. I've got try/catch on all methods in the VM and page. This error goes away if I hide those menu options and use clean pages so it could be something else. But I'm thinking that it's the appshell which is causing an issue. This is happening at the application entry method in the program.cs UIApplication.Main(args, null, typeof(AppDelegate));
Edit: The "second" issue seems to wrap around the DataContext class not releasing after navigating off. I don't think it's related to the question at hand but I'll leave it here in case there is something that is.
But, the issue I want to figure out first is why I cannot access the first page of the list, no matter what page I put there. The app starts on that page, but I can't click on it in the hamburger menu. I can click on menu items 2 & 3. I can reorder the items and it's always the top item defined in the <shellContent... section and any shellContent item that is #1 (first menu item in the shell menu), it cannot be navigated to again once I navigate off of it.
My appshell.xaml.cs is stock (no added routing for the test as the base level pages are defined in the appshell.xaml page.
appshell.xaml
namespace Manager;
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
The MauiProgram.cs has the pages defined.
eg builder.Services.AddTransient(); builder.Services.AddTransient();
I am running this on the iOS simulator and it was working at one point.
I'm trying a few things to isolate where the issue is, but I am not coming up with anything in my code.
Upvotes: 0
Views: 296
Reputation: 14434
First of all, there is a known issue: [regression/8.0.0-preview.3.8149] Header in flyout menu makes first menu item not clickable on IOS.
And it is a new bug in the .net 8.0 on iOS. It can work well in .net 7. In addition, for the workaround, you can add the Margin
for the Grid
in the <Shell.FlyoutHeaderTemplate>
. This will make the first shellcontent clickable but break the label in the grid. You can also give up the FlayoutHeader
to avoid this issue.
For the second issue, I can't reproduce it. You can post an new question with the steps and details to reproduce it.
Upvotes: 1