如何在选项卡页面中显示网页?

时间:2017-12-04 03:12:35

标签: xaml xamarin webview code-behind tabbedpage

有没有办法将网页显示为标签页?选项卡式页面有2个选项卡。一个用于联系,一个用于联系,是否可以将选项卡式页面的内容设置为“www.example.com/about”或“www.example.com/contact”等网址? 目前我只在选项卡页面上有一个按钮,用于打开浏览器。代码如下:

  public AboutPage()
    {
        InitializeComponent();
        this.Title = "About";


        StackLayout contact = new StackLayout
        {
            VerticalOptions = LayoutOptions.Center,
            Children = {
            new Label {
                HorizontalTextAlignment=TextAlignment.Center,
                Text = "contact here"
            }
            }
        };
        var browser = new WebView();
        var htmlSource = new HtmlWebViewSource();
        htmlSource.BaseUrl = "http://www.google.com";
        browser.Source = htmlSource;
        Button abtbutton = new Button
        {
            Text = "View about page"
        };
        abtbutton.Clicked += OnAboutBtnClicked;
        this.Children.Add(new ContentPage
        {
            Title = "About",
            Content = browser
        }
        );
        this.Children.Add(new ContentPage
        {
            Title = "Contact",
            Content = contact
        });
    }

    void OnAboutBtnClicked(object sender, EventArgs args)
    {
        Device.OpenUri(new Uri("http://www.google.com"));
    }

1 个答案:

答案 0 :(得分:1)

我认为你需要两个webView。

>>> [option for v in info.values() for option in v]
['option1', 'option2', 'option3', 'option4', 'option5', 'option6', 'option7', 'option8', 'option9', 'option10', 'option11']

enter image description here