2014-09-26 33 views
0

我目前正在學習Xamarin開發,看起來像一個很大的學習曲線。Xamarin - 我怎樣稱爲TabbedPage

那麼我有一個標籤頁類(TabbedPageTest.cs),我從TabbedPage繼承。

現在我該如何查看該頁面。

比方說,我想使用表格視圖中的單元格進行導航。

TableView tb = new TableView 
       { 
        Intent = TableIntent.Menu, 
        Root = new TableRoot 
        { 
         new TableSection("Tabbed Page Test") 
         { 
          new TextCell 
          { 
           // What all codes can I add here to navigate or view TabbedPageTest.cs? 
          } 
         } 
        } 
       } 

回答

2

//標籤頁演示代碼在PCL用於Xamarin.Forms

TabbedPage tabs = new TabbedPage(); 

    tabs.Children.Add(
     new NavigationPage (new MainPage() { Title = "Title for MainPage" }) { 
      Title = "Tile for TabbedPage Tab1" // Add this title for your TabbedPage 
     } 
    ); 

    tabs.Children.Add(
     new NavigationPage (new FirstPage() { Title = "Title for FirstPage" }) { 
      Title = "Tile for TabbedPage Tab2" // Add this title for your TabbedPage 
     } 
    ); 
    return tabs; 

希望這有助於

2

這裏是Xamarin我的標籤頁中的代碼窗體 ...

<?xml version="1.0" encoding="UTF-8"?> 
    <TabbedPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:me="clr-namespace:EvalUate;assembly=EvalUate" 
    x:Class="EvalUate.MainPage" 
    Title="EvalUate"> 
    <TabbedPage.Children> 
     <me:AppliancePage /> 
     <me:HelpPage /> 
     <me:LicensePage /> 
    </TabbedPage.Children> 
    </TabbedPage> 

有了到位,無需代碼,它會找到正確的頁面。

+0

對不起,我們不使用XAML代碼。我如何使用視圖或推送方法調用此方法...謝謝 – TBA 2014-09-27 04:43:26

2

您要求在C#中的代碼。這裏你去...

public partial class MainPage : TabbedPage // Note inherits from TabbedPage 
{ 
    public MainPage () 
    { 
     this.Title = "Tabbed Page Demo"; 
     var appliancePage = new AppliancePage (); 
     var helpPage = new HelpPage (); 
     this.Children.Add(appliancePage); 
     this.Children.Add(helpPage); 
    } 
} 

以上是在MainPage.cs。 MainPage.xaml中看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" <!-- note TabbedPage --> 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
x:Class="XamlToCSharpDemo.MainPage"> 
</TabbedPage> 

記住,每個子頁面(例如,HelpPage)都必須有一個標題...

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
x:Class="XamlToCSharpDemo.HelpPage" Title="Help"> <!-- Note Title --> 
    <ContentPage.Content> 
    <Label Text="Help Page"/> 
    </ContentPage.Content> 
</ContentPage>