Home > other >  Shell TitleView cant populate Layouts
Shell TitleView cant populate Layouts

Time:03-12

We are working on an MAUI app and facing a problem in navigating from and to tabs.

We have a shell app with a TabBar, inside we defined 5 tabs:

    <TabBar>
        <Tab Title="Home"
         Icon="homeicon.png">
            <ShellContent ContentTemplate="{DataTemplate Pages:FeedPage}" />
        </Tab>
        <Tab Title="Messages"
         Icon="messageicon.png">
            <ShellContent ContentTemplate="{DataTemplate Pages:MessagesPage}" />
         ...
    </TabBar>

We have also defined in one of the tabs xaml a Shell.TitleView like so:

<Shell.TitleView>
        <Grid Padding="5" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="5*"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>

        <ImageButton Grid.Column="2" Source="profileicon.png"
                   HorizontalOptions="CenterAndExpand"
                   VerticalOptions="CenterAndExpand"
                   Command="{Binding ProfileButtonTapped }" />
        <ImageButton Grid.Column="1" Source="coinicon.png"
                   ...
                   ...

    </Grid>
    </Shell.TitleView>

Our problem occurs when we try to go back to the tab in which we have the Shell.TitleView defined. the error we get is :

Java.Lang.IllegalStateException: 'The specified child already has a parent. You must call removeView() on the child's parent first.'

This error occurs with StackLayout on the title view as well... we did some digging and found out that if we remove the layouts from the TitleView the error isn't happening anymore so we guess it has something to do with it.

Edit 1: I have noticed this output every time I switch tabs

"Thread finished: #11 The thread 0xb has exited with code 0 (0x0). Thread started: #12 Thread finished: #10 The thread 0xa has exited with code 0 (0x0). [TabLayout] MODE_SCROLLABLE GRAVITY_FILL is not supported, GRAVITY_START will be used instead"

CodePudding user response:

Unfortunately it is a known bug in MAUI itself Page with TitleView crashes on Android when navigating back to it from Shell Tab #4506

  • Related