Skip to content

Instantly share code, notes, and snippets.

@edsnider edsnider/StaticTabs.xaml
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.