Skip to content

Instantly share code, notes, and snippets.

@edsnider
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsnider/e1dd04b58c4eaae1d2eb to your computer and use it in GitHub Desktop.
Save edsnider/e1dd04b58c4eaae1d2eb to your computer and use it in GitHub Desktop.
Static tabs in a Xamarin.Forms TabbedPage
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="StaticTabbedPageSample.Views.StaticTabs"
Title="Static Tabs Sample">
<TabbedPage.Children>
<ContentPage Title="Tab 1">
<StackLayout Orientation="Vertical" Padding="10,0">
<Label Text="This is the content for the first tab" />
<Button Text="Click here" />
</StackLayout>
</ContentPage>
<ContentPage Title="Tab 2">
<Label Text="This is the content for the second tab" />
</ContentPage>
</TabbedPage.Children>
</TabbedPage>
using Xamarin.Forms;
namespace StaticTabbedPageSample.Views
{
public class StaticTabs2 : TabbedPage
{
public StaticTabs2()
{
Title = "Static Tabs Sample 2";
// Tab 1
var tab1 = new ContentPage {Title = "Tab 1"};
var stack = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = new Thickness(10, 0)
};
var label1 = new Label {Text = "This is the content for the first tab"};
var button1 = new Button {Text = "Click here"};
stack.Children.Add(label1);
stack.Children.Add(button1);
tab1.Content = stack;
// Tab 2
var tab2 = new ContentPage {Title = "Tab 2"};
var label2 = new Label { Text = "This is the content for the second tab" };
tab2.Content = label2;
// Set tabs to page
Children.Add(tab1);
Children.Add(tab2);
}
}
}
using Xamarin.Forms;
namespace StaticTabbedPageSample.Views
{
public class StaticTabs3 : TabbedPage
{
public StaticTabs3()
{
Title = "Static Tabs Sample 3";
Children.Add(new Tab1Page());
Children.Add(new Tab2Page());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment