Insert the link to the pages inside a TabViewItem

Stefano M 91 Reputation points
2021-04-02T16:17:50.813+00:00

I have created a TabView and for each icon I am trying to insert as content the pages I created previously. I can't insert them inside the TabViewItem, visualStudio reports me as an error.

My pages are inside the 'Pagine' folder in Visual Studio
Screen

<xct:TabViewItem  
                TabWidth="{Binding TabWidth}"  
                Text="Home"  
                FontFamily="MyIcon"  
                ControlTemplate="{StaticResource TabItemTemplate}">  
            <xct:TabViewItem.Icon>  
                <FontImageSource  Color="Gray" FontFamily="MyIcon" Glyph="{x:Static dayr:FontIconClass.Home}"/>  
            </xct:TabViewItem.Icon>  
            <xct:TabViewItem.IconSelected>  
                <FontImageSource  Color="Black" FontFamily="MyIcon" Glyph="{x:Static dayr:FontIconClass.Home}"/>  
            </xct:TabViewItem.IconSelected>  
  
             //ERROR  
          <Myapp:MainPage></Myapp:MainPage>       
            </xct:TabViewItem>  

The error is:

Property 'Content' does not support values of type 'MainPage'

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,951 Reputation points
    2021-04-05T02:20:22.963+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    The error is: Property 'Content' does not support values of type 'MainPage'

    The xct:TabViewItem control is type of TemplatedView, we cannot place a contentPage inside it. It supports to use the ContentView, try using a contentView instead.

       <xct:TabViewItem  
           TabWidth="{Binding TabWidth}"  
           Text="Home"  
           FontFamily="MyIcon">  
           ...  
           <local:View1 />  
       </xct:TabViewItem>  
    

    Related doc about the Xamarin Community Toolkit TabView: https://devblogs.microsoft.com/xamarin/xamarin-community-toolkit-tabview/

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.