Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Xamarin.Forms;
namespace TabPageTestCase
{
public class App
{
public static Page GetMainPage ()
{
return new TabbedDemoPage ();
}
}
public class TabbedDemoPage : TabbedPage
{
public TabbedDemoPage ()
{
Title = "TabbedPage";
this.ItemsSource = new NamedColor[] {
new NamedColor ("Red"),
new NamedColor ("Yellow"),
new NamedColor ("Green"),
new NamedColor ("Aqua"),
new NamedColor ("Blue"),
new NamedColor ("Purple"),
new NamedColor ("Olive")
};
ItemTemplate = new DataTemplate (() => new TabPage ());
}
}
public class NamedColor
{
public string Name {
get;
set;
}
public NamedColor (string name)
{
Name = name;
}
}
public class TabPage : ContentPage
{
readonly Label myLabel;
public TabPage ()
{
myLabel = new Label {
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
};
myLabel.SetBinding (Label.TextProperty, "Name");
this.SetBinding (Page.TitleProperty, "Name");
Content = myLabel;
}
}
}
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.