2017-12-04 45 views
0

ウェブページをタブ付きページとして表示する方法はありますか?タブ付きページには2つのタブがあります。約1つと1つの連絡先のために、タブ付きページのコンテンツを "www.example.com/about"や "www.example.com/contact"のようなURLだけにすることは可能ですか? 現在のところ、ブラウザを開くタブ付きのページにボタンがあります。以下のコード:どのようにタブ付きページ内に表示するWebページを取得できますか?

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

私は2つの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 
}); 

enter image description here