简体   繁体   English

如何在Xamarin表单Web视图中创建新标签页

[英]How to create new tabs in xamarin forms web view

I want to make my web-view support multiple tabs . 我想使我的网络视图支持多个选项卡。 how to do it for example like this code : 例如下面的代码如何做:

browser.newtab(URL:"google.com",tabindex:1);

How to do it in android and ios ? 如何在android和ios中做到这一点?

Easiest solution is to go for tabbed page. 最简单的解决方案是转到选项卡式页面。 Example: 例:

    private ContentPage NewBrowserTab(string url)
    {
        var cp = new ContentPage();
        cp.Title = url;
        var wv = new WebView();
        wv.Source = url;
        cp.Content = wv;
        return cp;
    }

And tabbed page: 和标签页:

        TabbedPage tp = new TabbedPage();
        tp.Children.Add(NewBrowserTab("https://google.com"));
        tp.Children.Add(NewBrowserTab("https://xamarin.com"));

        App.Current.MainPage = new NavigationPage(tp);

That is not possible. 这是不可能的。 WebView (and its native counterparts) don't support the tab browsing. WebView (及其本机副本)不支持选项卡浏览。 So there is not a single line of code that will resolve your problem You must create the tab UI yourself and manage everything related to it. 因此,没有一行代码可以解决您的问题。您必须自己创建选项卡UI并管理与其相关的所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM