Search code examples
c#xamlmauitabbar.net-maui.shell

.Net Maui Tab Bar ShellContent Open Url instead of ContentPage


I am currently using the Tab Bar Navigation within my project and would like selecting a Tab to open a new External Browser.

I have tried navigating to the page and then loading a webview but this has too many limitations and just will not suffice.

I have googled to the usual 100th degree and I think I am asking to much of .Net Maui as the Tab Bar is for opening Shell Content which I believe is PageContent, but somebody might say No you can do this trick etc.

<Tab Title="Water">
      <Tab.Icon>
      <FontImageSource FontFamily="CustomIcons" Glyph="&#xe90b;" Size="Small"/>
      </Tab.Icon>
      // The line below I would like to have the ContentTemplate open a URL Template etc or 
      // or set a command in there to call my function below.
      <ShellContent ContentTemplate="{DataTemplate views:WaterPage}" />
</Tab>

The Shell Flyout had the Menu option to allow for commands on clicking of Icons, I am wondering if there is something similar I can do so I can have a handler sat on back doing something like below.

    public void OpenWaterWebPage(object sender, EventArgs e)
    {
        Uri uri = new Uri("https://www.MadeUpSiteName.co.uk/WaterSports");

        OpenHyperLink(uri);
    }

Solution

  • I also have struggled with this. There is no way to set a command or events of any sort. You can only open content pages, which is frustrating.

    I ended up using Sharpnado Tabs to render the Tabbed view of my apps. You lose the capability of navigating using shell through the tabs. But it enables you to do anything with your tabs and tabs views.

    https://github.com/roubachof/Sharpnado.Tabs

    If you want to explore this path further I can give you guidance.