[英]How Do I get a webpage to display inside a tabbed page?
有没有一种方法可以将网页显示为选项卡式页面? 该选项卡式页面具有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"));
}
我认为您需要两个webView。
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
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.