<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TestXam.Views.MainPage"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:local="clr-namespace:TestXam.Views;assembly=TestXam"
android:TabbedPage.ToolbarPlacement="Bottom" Title="{Binding currentPageName}">
<local:ContentOnePage />
<local:ContentTwoPage />
TabbedPage/>
|
public MainPageViewModel(int selectedIndex)
{
GetTitleName(selectedIndex);
}
private void GetTitleName(int index) {
SelectedTabTitle = Items[index].Title;
} |
|
<tabView:SfTabView Items="{Binding Items}" VisibleHeaderCount="-1" VerticalOptions="FillAndExpand" x:Name="tabView" SelectedIndex="{Binding TabViewSelectedIndex,Mode=TwoWay}" BackgroundColor="Aqua">
</tabView:SfTabView> |
|
private int tabViewSelectedIndex = 1;
public int TabViewSelectedIndex
{
get { return tabViewSelectedIndex; }
set
{
tabViewSelectedIndex = value;
NotifyPropertyChanged("TabViewSelectedIndex");
} |
|
<tabView:SfTabView Items="{Binding Items}" VisibleHeaderCount="-1" TabHeight="100" VerticalOptions="FillAndExpand" x:Name="tabView" SelectedIndex="{Binding TabViewSelectedIndex,Mode=TwoWay}" BackgroundColor="Aqua">
</tabView:SfTabView> |
|
public MainPageViewModel(int selectedIndex)
{
Items = new TabItemCollection();
Label page1Header = new Label();
page1Header.Text = "Page1";
page1Header.Padding = 5;
page1Header.HorizontalTextAlignment = TextAlignment.Center;
page1Header.VerticalTextAlignment = TextAlignment.Center;
…
Items.Add(new SfTabItem { Content = page1.Content, Title = "Page1", HeaderContent = page1Header }); ;
Items.Add(new SfTabItem { Content = page2.Content, Title = "Page2", HeaderContent = page2Header });
Items.Add(new SfTabItem { Content = page3.Content, Title = "Page3", HeaderContent = page3Header });
GetTitleName(selectedIndex);
}
|
|
public TabItemCollection Items
{
get { return items; }
set
{
items = value;
NotifyPropertyChanged("Items");
}
}
public MainPageViewModel(int selectedIndex)
{
Items = new TabItemCollection();
TabViewItemPage1 page1 = new TabViewItemPage1();
TabViewItemPage2 page2 = new TabViewItemPage2();
TabViewItemPage3 page3 = new TabViewItemPage3();
Items.Add(new SfTabItem { Content = page1.Content, Title = "Page1", HeaderContent = page1Header }); ;
Items.Add(new SfTabItem { Content = page2.Content, Title = "Page2", HeaderContent = page2Header });
Items.Add(new SfTabItem { Content = page3.Content, Title = "Page3", HeaderContent = page3Header });
} |

<tabView:SfTabView TabHeaderPosition="Bottom" TabHeight="100"
TabHeaderBackgroundColor="{Binding TabBackgroundColor}"
DisplayMode="ImageWithText" VisibleHeaderCount="3" SelectedIndex="{Binding TabViewSelectedIndex, Mode=TwoWay}">
<tabView:SfTabView.Behaviors>
<behaviors:EventToCommandBehavior Command="{Binding SelectionChangedCommand}"
EventName="SelectionChanged" />
tabView:SfTabView.Behaviors>
<tabView:SfTabItem Title="Content1" ImageSource="cheeseburger.png" >
<tabView:SfTabItem.Content>
<Grid BackgroundColor="LightSkyBlue" x:Name="AllContactsGrid">
<ListView ItemsSource="{Binding ClarityCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding Description}">Label>
ViewCell>
DataTemplate>
ListView.ItemTemplate>
ListView>
Grid>
tabView:SfTabItem.Content>
tabView:SfTabItem>
<tabView:SfTabItem Title="Content2" ImageSource="cheeseburger.png">
<tabView:SfTabItem.Content>
<Grid BackgroundColor="LightBlue" x:Name="AllContactsGrid2" />
tabView:SfTabItem.Content>
tabView:SfTabItem>
<tabView:SfTabItem Title="Content3" ImageSource="cheeseburger.png">
<tabView:SfTabItem.Content>
<Grid BackgroundColor="LightGreen" x:Name="AllContactsGrid3" />
tabView:SfTabItem.Content>
tabView:SfTabItem>
tabView:SfTabView>
Hi Reza,
Thanks for the update.
We will create sample based on your requirement and update the details on
before end of the day Today.
Regards,
Sakthivel P.
<tabView:SfTabView TabHeaderPosition="Bottom" TabHeight="65" VisibleHeaderCount="-1" EnableSwiping="False"> <!-- Items="{Binding MainTabItems}"> --> <tabView:SfTabView.Behaviors> <behaviors:EventToCommandBehavior Command="{Binding SelectionChangedCommand}" EventName="SelectionChanged" /> </tabView:SfTabView.Behaviors> <tabView:SfTabView.Items> <tabView:SfTabItem Title="Tab1"> <tabView:SfTabItem.Content> <tabView:SfTabView Items="{Binding ContrastTabItems}" TabHeaderPosition="Top" VisibleHeaderCount="-1" EnableSwiping="False"> <!-- <tabView:SfTabView.Items> --> <!-- --> <!-- <tabView:SfTabItem Title="SubTab1" /> --> <!-- <tabView:SfTabItem Title="SubTab2" /> --> <!-- --> <!-- </tabView:SfTabView.Items> --> </tabView:SfTabView> </tabView:SfTabItem.Content> </tabView:SfTabItem> <tabView:SfTabItem Title="Tab2" /> <tabView:SfTabItem Title="Tab3" /> </tabView:SfTabView.Items> </tabView:SfTabView>
|
<tabView:SfTabItem.HeaderContent>
<ContentView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
</Grid.RowDefinitions>
<Label FontFamily="Icons" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text=""/>
<Label Text="Tab1" FontSize="12" Grid.Row="1" HorizontalTextAlignment="Center"/>
</Grid>
</ContentView>
</tabView:SfTabItem.HeaderContent> |
|
<tabView:SfTabView x:Name="tabView" VisibleHeaderCount="-1" TabHeight="65" SelectionChanged="tabView_SelectionChanged" TabHeaderPosition="Bottom">
<tabView:SfTabItem>
<tabView:SfTabItem.HeaderContent>
…
</tabView:SfTabItem.HeaderContent>
<tabView:SfTabItem.Content>
<tabView:SfTabView Items="{Binding Items}" VisibleHeaderCount="-1"/>
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
|
|
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
TabItemPage1 page1 = new TabItemPage1();
TabItemPage2 page2 = new TabItemPage2();
tabView.Items.Add(new SfTabItem { Content = page1.Content, HeaderContent = new TabHeader1("\ue71a", "Tab2") }); ;
tabView.Items.Add(new SfTabItem { Content = page2.Content, HeaderContent = new TabHeader1("\ue71e", "Tab3") });
SetTextColor(tabView, tabView.SelectedIndex);
BindingContext = new TabViewModel();
}
} |
|
<tabView:SfTabView x:Name="tabView" VisibleHeaderCount="-1" TabHeight="65" SelectionChanged="tabView_SelectionChanged" TabHeaderPosition="Bottom">
<tabView:SfTabItem>
<tabView:SfTabItem.Content>
<tabView:SfTabView x:Name="nestedTab" VisibleHeaderCount="-1">
<tabView:SfTabItem Title="SubTab2">
<tabView:SfTabItem.Content>
<local:SecondView/>
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Title="SubTab3">
<tabView:SfTabItem.Content>
<local:THirdView/>
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
</tabView:SfTabItem.Content>
</tabView:SfTabItem> </tabView:SfTabView> |
|
public MainPage()
{
TabItemPage1 page1 = new TabItemPage1();
InitializeComponent();
nestedTab.Items.Insert(0, (new SfTabItem { Content = page1.Content, Title = "SubTab1" }));
} |
|
<tabView:SfTabItem.HeaderContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.1*" />
</Grid.RowDefinitions>
<Grid HeightRequest="1" BackgroundColor="LightGray"/>
<Label FontFamily="Icons" Grid.Row="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text=""/>
<Label Text="Tab1" FontSize="12" Grid.Row="2" HorizontalTextAlignment="Center"/>
</Grid>
</tabView:SfTabItem.HeaderContent> |
<tabView:SfTabItem Title="Step" FontIconFontColor="{StaticResource Gray-400}" FontIconFontFamily="FontIcons" FontIconFontSize="Small" IconFont="{StaticResource Icon2}" SelectionColor="{StaticResource Gray-600}" TitleFontColor="{StaticResource Gray-400}" TitleFontSize="Micro" TitleFontFamily="Font-Regular"/>
|
public TabViewModel(SfTabView tabView)
{
SetItems();
sfTabView = tabView;
sfTabView.Items.Insert(0, (new SfTabItem { Content = page1.Content, Title = "SubTab1" }));
} |
|
<tabView:SfTabItem.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="1"/>
</Grid.RowDefinitions>
<tabView:SfTabView x:Name="nestedTab" VisibleHeaderCount="-1">
<tabView:SfTabItem Title="SubTab2">
<tabView:SfTabItem.Content>
<local:SecondView/>
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Title="SubTab3">
<tabView:SfTabItem.Content>
<local:THirdView/>
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
<Grid HeightRequest="1" Grid.Row="1" BackgroundColor="LightGray"/>
</Grid>
</tabView:SfTabItem.Content> |
ContrastContent Content1 = new ContrastContent(); ClarityContent Content2 = new ClarityContent(); ContrastTabItems = new TabItemCollection() { new SfTabItem() { Title = "Contrast", Content = Content1.Content, TitleFontFamily = "Font-Regular", TitleFontColor = ResourceHelpers.GetColorFromResourceKey("Gray-400"), TitleFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), SelectionColor = ResourceHelpers.GetColorFromResourceKey("Gray-600") }, new SfTabItem() { Title = "Clarity", Content = Content2.Content, TitleFontFamily = "Font-Regular", TitleFontColor = ResourceHelpers.GetColorFromResourceKey("Gray-400"), TitleFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), SelectionColor = ResourceHelpers.GetColorFromResourceKey("Gray-600") } };
Grid content1 = new Grid() { RowDefinitions = { new RowDefinition {Height = new GridLength(1)}, new RowDefinition {Height = new GridLength(1, GridUnitType.Star)} } }; Grid.SetRow(contrastContent, 1); content1.Children.Add(new BoxView() { BackgroundColor = Color.Red, HeightRequest = 1 }); content1.Children.Add(contrastContent.Content); ContrastTabItems = new TabItemCollection() { new SfTabItem() { Title = "Contrast", Content = content1, TitleFontFamily = "Font-Regular", TitleFontColor = ResourceHelpers.GetColorFromResourceKey("Gray-400"), TitleFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), SelectionColor = ResourceHelpers.GetColorFromResourceKey("Gray-600") },
|
public class TabViewModel
{
private TabItemCollection subTabItems;
public TabItemCollection SubTabItems
{
get { return subTabItems; }
set
{
subTabItems = value;
}
}
public TabViewModel()
{
SetItems();
SubTabItems = new TabItemCollection();
SubTabItems.Add(new SfTabItem { Content = SetTabItemContent(new TabItemPage1().Content), Title = "Contrast" });
SubTabItems.Add(new SfTabItem { Content = SetTabItemContent(new TabItemPage1().Content), Title = "Clarity" });
}
private Grid SetTabItemContent(View tabItemContent)
{
Grid mainGrid = new Grid();
Grid content1 = new Grid()
{
RowDefinitions =
{
new RowDefinition {Height = new GridLength(1)},
new RowDefinition {Height = new GridLength(1, GridUnitType.Star)}
}
};
Grid.SetRow(tabItemContent, 1);
content1.Children.Add(new BoxView()
{
BackgroundColor = Color.Green,
HeightRequest = 1
});
content1.Children.Add(tabItemContent);
AbsoluteLayout absoluteLayout = new AbsoluteLayout
{
Margin = new Thickness(20)
};
absoluteLayout.Children.Add(new Button
{
BackgroundColor = Color.Red,
}, new Rectangle(250, 300, 60, 60));
Grid.SetRow(absoluteLayout, 0);
mainGrid.Children.Add(content1);
mainGrid.Children.Add(absoluteLayout);
return mainGrid;
} |