Toolbar Item on one Tab only

NeidennX 1 Reputation point
2022-01-17T23:23:02.017+00:00

Hi team, hope you're all good, im creating an app that has a TabbedPage, my question is, if i can add a Toolbar Item that shows up on only one of the tabs ? is this possible ?

Regards

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,971 Reputation points
    2022-01-18T01:45:08.047+00:00

    Hello @NeidennX ,​

    Welcome to our Microsoft Q&A platform!

    if i can add a Toolbar Item that shows up on only one of the tabs ? is this possible ?

    Yes, it's available to do that. First add the toolbar item for the tab page.

       <ContentPage ...  
               x:Class="TestApplication1.TestPage">  
           <ContentPage.ToolbarItems>  
               <ToolbarItem IconImageSource="img"/>  
           </ContentPage.ToolbarItems>  
           ...  
       </ContentPage>  
    

    If you plan to add the nav bar for all the tabs, you could just wrap the tabbedPage in the NavigationPage as below.

       public partial class App : Application  
       {  
           public App()  
           {  
               InitializeComponent();  
               MainPage = new NavigationPage(new TabbedPage1());  
           }  
       }  
    

    If you just want to display the nav bar for the specific tab page, you could only wrap the content page in the NavigationPage.

       <?xml version="1.0" encoding="utf-8" ?>  
       <TabbedPage ...  
            x:Class="TestApplication1.TabbedPage1">  
           <ContentPage Title="Tab 1" />  
           <ContentPage Title="Tab 2" />  
           <NavigationPage>  
               <x:Arguments>  
                   <local:TestPage Title="Tab 3" />  
               </x:Arguments>  
           </NavigationPage>  
       </TabbedPage>  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.