Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 如何使网页显示在选项卡式页面中?_Xaml_Xamarin_Webview_Code Behind_Tabbedpage - Fatal编程技术网

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

Xaml 如何使网页显示在选项卡式页面中?,xaml,xamarin,webview,code-behind,tabbedpage,Xaml,Xamarin,Webview,Code Behind,Tabbedpage,有没有办法将网页显示为选项卡式页面?选项卡式页面有两个选项卡。一个用于about,一个用于contact,是否可以将选项卡式页面的内容作为类似“www.example.com/about”或“www.example.com/contact”的url? 目前,我只在选项卡页面上有一个按钮,可以打开浏览器。代码如下: public AboutPage() { InitializeComponent(); this.Title = "About";

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

  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"));
    }

我想你需要两个网络视图

var browser = new WebView();
browser.Source = new UrlWebViewSource { Url = "https://developer.xamarin.com/" };
this.Children.Add(new ContentPage
{
    Title = "About",
    Content = browser
}
);

var browser2 = new WebView();
browser2.Source = new UrlWebViewSource { Url = "https://stackoverflow.com/" };
this.Children.Add(new ContentPage
{
    Title = "Contact",
    Content = browser2
});