2016-10-30 43 views
1

Iam使用選項卡導航並使用頁面並希望打開一個新頁面。使用選項卡導航打開新頁面

在我app.xaml.cs我創建導航頁:

public App() 
{ 
    InitializeComponent(); 
    MainPage = new NavigationPage(new RootPage()); 
} 

在RootPage我填的是導航:

public RootPage() 
{ 
     NavigationPage.SetHasNavigationBar(this, false); 

     Children.Add(new TestPage1 
     { 
      Title = "TestPage1" 
     }); 

     Children.Add(new TestPage2 
     { 
      Title = "TestPage2" 
     }); 
     Children.Add(new TestPage3 
     { 
      Title = "TestPage3" 
     }); 
} 

這種類型的導航效果很好已經和看起來不錯。 現在我想在TestPage3中翻開新的一頁: TestPage3.xaml:

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      x:Class="DemoApplication.TestPage3"> 
    <Button x:Name="openSetup" Clicked="ItemClicked" Text="open Settings"/> 
</ContentPage> 

TestPage3.xaml.cs:

namespace DemoApplication 
{ 
    public partial class TestPage3 : ContentPage 
    { 
     public TestPage3() 
     { 
      InitializeComponent(); 
     } 
     void ItemClicked(object sender, EventArgs e) 
     { 
      Navigation.PushAsync(new TestPage4()); 
     } 
    } 
} 

這也適用,但犯規好看。

原來的標籤導航以下新內容加載和它加載的標籤導航消失後 - 所以第4頁的內容是那種跳來跳去:)

在其他應用程序,如的SoundCloud他們做同樣的,但它看起來方式更順暢。

有沒有什麼辦法可以像後移導航之間的標籤導航更平滑?

感謝您的幫助:)

如果您想在標籤內瀏覽

回答

2

,每個標籤應該有它自己的NavigationPage。 TabbedPage本身不應位於NavigationPage內。

MainPage = new RootPage(); 

Children.Add(new NavigationPage(new TestPage3 
     { 
      Title = "TestPage3" 
     })); 
相關問題