MAUI Tabbed Page crashes when it is called from another page

431 views Asked by At

Simple example Main Page (which is a simple content page with a button) Second Page (which is the tabbed page displayed when the button is pressed)

The code works under Windows, but on Android crashes during startup with "fragment viewid not found"

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          x:Class="TabbedMaui.MainPage"
             xmlns:local="clr-namespace:TabbedMaui" 
      >
<Button
    Text="Go" Clicked="Button_Clicked"></Button>
ed</ContentPage>

The second page is shown in the code block

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TabbedMaui.SecondPage"
             xmlns:local="clr-namespace:TabbedMaui" 
        x:DataType="local:SecondPage"
             Title="Some title" BackgroundColor="blue">
<ContentPage Title="Page 1" BackgroundColor="Red">
    <VerticalStackLayout >
        <Label Text="Hello"></Label>
    </VerticalStackLayout>
             </ContentPage>
<ContentPage Title="Page 2" BackgroundColor="Yellow"></ContentPage>
<ContentPage Title="Page 3"></ContentPage>
</TabbedPage>
1

There are 1 answers

2
Alexandar May - MSFT On

This issue can be reproduced here. And it is a known issue that being tracked in the link below, you can follow up there.

https://github.com/dotnet/maui/issues/7615

Currently, you cannot mix TabbedPage together with MAUI Shell as the official docs states clearly below:

TabbedPage is incompatible with .NET MAUI Shell apps, and an exception will be thrown if you attempt to use TabbedPage in a Shell app.

As an alternative workaround, you may be able to set the App.MainPage to a TabbedPage to get it resolved.