.NET MAUI Dynamic Tab page

1.2k Views Asked by At

I am having issue to implement dynamic tab page in .NET MAUI project. Can we add tabs into Navigation page at runtime to open Webpage. I am trying to implement functionality model like Chrome or Edge to open web URLs in separate tab.

1

There are 1 best solutions below

3
Liyun Zhang - MSFT On BEST ANSWER

Can we add tabs into Navigation page at runtime to open Webpage

What does the webpage mean? At first, if you want to add a new tab into the TabbedPage when the user operates in the child page, you can use the the following code in the child page:

var tabbedpage = this.Parent as TabbedPage;
tabbedpage.Children.Add(new ChildPage());

And then if the ChildPage just have a webview in it and you want to add a new tab when the webview navigates to a new url. You can add a Navigating event to the webview and pass the url to the child page.

Update

You can create a construction method which has a parameter for the ChildPage, such as:

public ChildPage(string url)
{
   //use the url here
}