<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<tabView:SfTabView Items="{Binding Items}"/> |
public class ViewModel : INotifyPropertyChanged
{
private TabItemCollection items;
public TabItemCollection Items
{
get { return items; }
set
{
items = value;
}
}
public ViewModel()
{
Items = new TabItemCollection();
Items.Add(new SfTabItem { Content = new Page1(), Title = "Page1" });
Items.Add(new SfTabItem { Content = new Page2(), Title = "Page2" });
Items.Add(new SfTabItem { Content = new Page3(), Title = "Page3" });
}
} |
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="TabViewSample.Page1">
<ContentView.Content>
<Button
WidthRequest="150"
HeightRequest="150"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Clicked="Button_Clicked"
Text="Home"/>
</ContentView.Content>
</ContentView> |
void Button_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new NextPage());
} |
private void TabView_SelectionChanged(object sender, Syncfusion.XForms.TabView.SelectionChangedEventArgs e)
{
if (e.Index == 0)
{
FirstPage firstPage = new FirstPage();
tab1.Content = firstPage.Content;
}
else if (e.Index == 1)
{
SecondPage secondPage = new SecondPage();
tab2.Content = secondPage.Content;
}
else
{
ThirdPage thirdPage = new ThirdPage();
tab3.Content = thirdPage.Content;
}
}
|