Class SfTabView
Represents a tab view control that contains multiple items that share the same space on the screen.
Inheritance
Namespace: Syncfusion.Maui.Toolkit.TabView
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public class SfTabView : ContentView, IParentThemeElement, IThemeElement
Examples
The following example shows how to initialize the tab view.
<tabView:SfTabView x:Name="tabView">
<tabView:SfTabView.Items>
<tabView:SfTabItem Header="Item 1">
<tabView:SfTabItem.Content>
<Grid BackgroundColor="Red" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="Item 2">
<tabView:SfTabItem.Content>
<Grid BackgroundColor="Green" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="Item 3">
<tabView:SfTabItem.Content>
<Grid BackgroundColor="Blue" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView.Items>
</tabView:SfTabView>
Constructors
SfTabView()
Initializes a new instance of the SfTabView class.
Declaration
public SfTabView()
Fields
ContentItemTemplateProperty
Identifies the ContentItemTemplate bindable property.
Declaration
public static readonly BindableProperty ContentItemTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ContentTransitionDurationProperty
Identifies the ContentTransitionDuration bindable property.
Declaration
public static readonly BindableProperty ContentTransitionDurationProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
EnableSwipingProperty
Identifies the EnableSwiping bindable property.
Declaration
public static readonly BindableProperty EnableSwipingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
EnableVirtualizationProperty
Identifies the EnableVirtualization bindable property.
Declaration
public static readonly BindableProperty EnableVirtualizationProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
FontAutoScalingEnabledProperty
Identifies the FontAutoScalingEnabled bindable property.
Declaration
public static readonly BindableProperty FontAutoScalingEnabledProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
HeaderDisplayModeProperty
Identifies the HeaderDisplayMode bindable property.
Declaration
public static readonly BindableProperty HeaderDisplayModeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
HeaderHorizontalTextAlignmentProperty
Identifies the HeaderHorizontalTextAlignment bindable property.
Declaration
public static readonly BindableProperty HeaderHorizontalTextAlignmentProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
HeaderItemTemplateProperty
Identifies the HeaderItemTemplate bindable property.
Declaration
public static readonly BindableProperty HeaderItemTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IndicatorBackgroundProperty
Identifies the IndicatorBackground bindable property.
Declaration
public static readonly BindableProperty IndicatorBackgroundProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IndicatorCornerRadiusProperty
Identifies the IndicatorCornerRadius bindable property.
Declaration
public static readonly BindableProperty IndicatorCornerRadiusProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IndicatorPlacementProperty
Identifies the IndicatorPlacement bindable property.
Declaration
public static readonly BindableProperty IndicatorPlacementProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IndicatorStrokeThicknessProperty
Identifies the IndicatorStrokeThickness bindable property.
Declaration
public static readonly BindableProperty IndicatorStrokeThicknessProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for IndicatorStrokeThickness bindable property. |
IndicatorWidthModeProperty
Identifies the IndicatorWidthMode bindable property.
Declaration
public static readonly BindableProperty IndicatorWidthModeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
IsScrollButtonEnabledProperty
Identifies the IsScrollButtonEnabled bindable property.
Declaration
public static readonly BindableProperty IsScrollButtonEnabledProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ItemsProperty
Identifies the Items bindable property.
Declaration
public static readonly BindableProperty ItemsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ItemsSourceProperty
Identifies the ItemsSource bindable property.
Declaration
public static readonly BindableProperty ItemsSourceProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ScrollButtonBackgroundProperty
Identifies the ScrollButtonBackground bindable property.
Declaration
public static readonly BindableProperty ScrollButtonBackgroundProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
ScrollButtonColorProperty
Identifies the ScrollButtonColor bindable property.
Declaration
public static readonly BindableProperty ScrollButtonColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
SelectedIndexProperty
Identifies the SelectedIndex bindable property.
Declaration
public static readonly BindableProperty SelectedIndexProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TabBarBackgroundProperty
Identifies the TabBarBackground bindable property.
Declaration
public static readonly BindableProperty TabBarBackgroundProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TabBarHeightProperty
Identifies the TabBarHeight bindable property.
Declaration
public static readonly BindableProperty TabBarHeightProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TabBarPlacementProperty
Identifies the TabBarPlacement bindable property.
Declaration
public static readonly BindableProperty TabBarPlacementProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TabHeaderPaddingProperty
Identifies the TabHeaderPadding bindable property.
Declaration
public static readonly BindableProperty TabHeaderPaddingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TabWidthModeProperty
Identifies the TabWidthMode bindable property.
Declaration
public static readonly BindableProperty TabWidthModeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Properties
ContentItemTemplate
Gets or sets the template that is used to display the content.
Declaration
public DataTemplate ContentItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | A Microsoft.Maui.Controls.DataTemplate object that is used to display the content. The default is null. |
Examples
Here is an example of how to set the ContentItemTemplate property.
<tabView:SfTabView ItemsSource="{Binding TabItems}" >
<tabView:SfTabView.ContentItemTemplate>
<DataTemplate>
<Label TextColor = "Black" Text="{Binding Name}" />
</DataTemplate>
</tabView:SfTabView.ContentItemTemplate>
</tabView:SfTabView>
ContentTransitionDuration
Gets or sets a value that can be used to modify the duration of content transition in the tab view.
Declaration
public double ContentTransitionDuration { get; set; }
Property Value
Type | Description |
---|---|
System.Double | A double value that specifies the duration of the content transition. The default value is 100. |
Examples
Here is an example of how to set the ContentTransitionDuration property.
EnableSwiping
Gets or sets a value indicating whether swiping is enabled in SfTabView.
Declaration
public bool EnableSwiping { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether swiping is enabled. The default value is false. |
Examples
Here is an example of how to set the EnableSwiping property.
<tabView:SfTabView EnableSwiping="True">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 2">
<tabView:SfTabItem.Content>
<Label Text="More Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
EnableVirtualization
Gets or sets a value indicating whether lazy loading is enabled during the initial load.
Declaration
public bool EnableVirtualization { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether lazy loading is enabled. The default value is false. |
Examples
Here is an example of how to set the EnableVirtualization property.
FontAutoScalingEnabled
Gets or sets a value that determines whether the font of the control should scale automatically according to the operating system settings.
Declaration
public bool FontAutoScalingEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether font auto-scaling is enabled. The default value is false. |
Examples
Here is an example of how to set the FontAutoScalingEnabled property.
<tabView:SfTabView FontAutoScalingEnabled="True">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
HeaderDisplayMode
Gets or sets the display mode for the tab header, determining whether to show the image or text.
Declaration
public TabBarDisplayMode HeaderDisplayMode { get; set; }
Property Value
Type | Description |
---|---|
TabBarDisplayMode | It accepts the TabBarDisplayMode values, and the default value is Default. |
Remarks
When the HeaderDisplayMode is set to Default, the image and text will be displayed on the tab bar based on the Header and ImageSource properties of the tab item.
Examples
Here is an example of how to set the HeaderDisplayMode property.
<tabView:SfTabView HeaderDisplayMode="Text">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
HeaderHorizontalTextAlignment
Gets or sets a value that can be used to customize the horizontal text alignment in tab header.
Declaration
public TextAlignment HeaderHorizontalTextAlignment { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.TextAlignment | It accepts the HeaderHorizontalTextAlignment values, and the default value is Microsoft.Maui.TextAlignment.Center. |
Examples
Here is an example of how to set the HeaderHorizontalTextAlignment property.
<tabView:SfTabView HeaderHorizontalTextAlignment="Center">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
HeaderItemTemplate
Gets or sets the template that is used to display the header item.
Declaration
public DataTemplate HeaderItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | A Microsoft.Maui.Controls.DataTemplate object that is used to display the header item. The default is null. |
Examples
Here is an example of how to set the HeaderItemTemplate property.
<tabView:SfTabView ItemsSource="{Binding TabItems}">
<tabView:SfTabView.HeaderItemTemplate>
<DataTemplate >
<Label Padding = "5,10,10,10" Text="{Binding Name}"/>
</DataTemplate>
</tabView:SfTabView.HeaderItemTemplate>
</tabView:SfTabView>
IndicatorBackground
Gets or sets a brush that describes the selection indicator's background.
Declaration
public Brush IndicatorBackground { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | Specifies the background of the selection indicator. The default value is SolidColorBrush(Color.FromArgb("#6200EE")). |
Examples
Here is an example of how to set the IndicatorBackground property.
<tabView:SfTabView IndicatorBackground="Red">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
IndicatorCornerRadius
Gets or sets a value that can be used to customize the corner radius of the selection indicator.
Declaration
public CornerRadius IndicatorCornerRadius { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.CornerRadius | A Microsoft.Maui.CornerRadius value that specifies the corner radius of the selection indicator. The default value is -1. |
Examples
Here is an example of how to set the IndicatorCornerRadius property.
<tabView:SfTabView IndicatorCornerRadius="5,5,5,5">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
IndicatorPlacement
Gets or sets the placement of the selection indication.
Declaration
public TabIndicatorPlacement IndicatorPlacement { get; set; }
Property Value
Type | Description |
---|---|
TabIndicatorPlacement | One of the TabIndicatorPlacement enumeration that specifies the placement of the selection indicator. The default mode is Bottom. |
Examples
Here is an example of how to set the IndicatorPlacement property.
<tabView:SfTabView IndicatorPlacement="Fill">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
IndicatorStrokeThickness
Gets or sets a value that can be used to customize the indicator’s border height.
Declaration
public double IndicatorStrokeThickness { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts the double values and the default value is 3. |
IndicatorWidthMode
Gets or sets the value that can be used to customize the indicator width in the tab header.
Declaration
public IndicatorWidthMode IndicatorWidthMode { get; set; }
Property Value
Type | Description |
---|---|
IndicatorWidthMode | It accepts IndicatorWidthMode values and the default value is Fit. |
Remarks
It's not applicable when the IndicatorPlacement is Fill.
Examples
Here is an example of how to set the IndicatorWidthMode property.
<tabView:SfTabView IndicatorWidthMode="Fit">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
IsScrollButtonEnabled
Gets or sets a value indicating whether to enable the scroll buttons.
Declaration
public bool IsScrollButtonEnabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value indicating whether the scroll buttons are enabled. The default value is false. |
Examples
Here is an example of how to set the IsScrollButtonEnabled property.
<tabView:SfTabView IsScrollButtonEnabled="True">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 2">
<tabView:SfTabItem.Content>
<Label Text="More Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
Items
Gets or sets the collection used to populate the content of the SfTabView.
Declaration
public TabItemCollection Items { get; set; }
Property Value
Type | Description |
---|---|
TabItemCollection | The collection used to populate the content of the SfTabView. The default is an empty collection. |
Examples
Here is an example of how to set the Items property.
<tabView:SfTabView>
<tabView:SfTabView.Items>
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView.Items>
</tabView:SfTabView>
ItemsSource
Gets or sets the collection used to populate the content of the SfTabView.
Declaration
public IList ItemsSource { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.IList | The collection used to populate the content of the Tab View. The default is an empty collection. |
Examples
Here is an example of how to set the ItemsSource property.
ScrollButtonBackground
Gets or sets a value that can be used to customize the scroll button’s background color in the SfTabView.
Declaration
public Brush ScrollButtonBackground { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | A Microsoft.Maui.Controls.Brush value that specifies the background color of the scroll button. |
ScrollButtonColor
Gets or sets a value that can be used to customize the scroll button’s foreground color in the SfTabView.
Declaration
public Color ScrollButtonColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | A Microsoft.Maui.Graphics.Color value that specifies the foreground color of the scroll button. |
SelectedIndex
Gets or sets the index specifying the currently selected item.
Declaration
public int SelectedIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | A zero-based index of the currently selected item. |
Examples
Here is an example of how to set the SelectedIndex property.
<tabView:SfTabView SelectedIndex="2">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content 1" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 2">
<tabView:SfTabItem.Content>
<Label Text="Content 2" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 3">
<tabView:SfTabItem.Content>
<Label Text="Content 3" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
TabBarBackground
Gets or sets the background color of the tab bar.
Declaration
public Brush TabBarBackground { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | The background color of the tab bar. The default value is null. |
Examples
Here is an example of how to set the TabBarBackground property.
<tabView:SfTabView TabBarBackground="Pink">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
TabBarHeight
Gets or sets the height of the tab header.
Declaration
public double TabBarHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Specifies the height of the tab header. The default value is 48d. |
Examples
Here is an example of how to set the TabBarHeight property.
<tabView:SfTabView TabBarHeight="80">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
TabBarPlacement
Gets or sets whether the tab header should be at the bottom or at the top of the tab content.
Declaration
public TabBarPlacement TabBarPlacement { get; set; }
Property Value
Type | Description |
---|---|
TabBarPlacement | One of the TabBarPlacement enumeration that specifies the placement of the tab bar. The default mode is Top. |
Examples
Here is an example of how to set the TabBarPlacement property.
<tabView:SfTabView TabBarPlacement="Bottom">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
TabHeaderPadding
Gets or sets the value that can be used to customize the padding of the tab header.
Declaration
public Thickness TabHeaderPadding { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Thickness | Specifies the padding of the tab header. The default value is new Thickness(52,0,52,0). |
Remarks
Note: This is only applied to the SizeToContent type of TabWidthMode.
Examples
Here is an example of how to set the TabHeaderPadding property.
<tabView:SfTabView TabWidthMode="SizeToContent" TabHeaderPadding="5,10,5,10">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content 1" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 2">
<tabView:SfTabItem.Content>
<Label Text="Content 2" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
<tabView:SfTabItem Header="TAB 3">
<tabView:SfTabItem.Content>
<Label Text="Content 3" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
TabWidthMode
Gets or sets the value for determining the width mode of each tab.
Declaration
public TabWidthMode TabWidthMode { get; set; }
Property Value
Type | Description |
---|---|
TabWidthMode | One of the TabWidthMode enumeration values that specifies the tab item's width. The default mode is Default. |
Examples
Here is an example of how to set the TabWidthMode property.
<tabView:SfTabView TabWidthMode="SizeToContent">
<tabView:SfTabItem Header="TAB 1">
<tabView:SfTabItem.Content>
<Label Text="Content" />
</tabView:SfTabItem.Content>
</tabView:SfTabItem>
</tabView:SfTabView>
Events
SelectionChanged
Occurs when the current selection is changed.
Declaration
public event EventHandler<TabSelectionChangedEventArgs> SelectionChanged
Event Type
Type |
---|
System.EventHandler<TabSelectionChangedEventArgs> |
Examples
Here is an example of how to register the SelectionChanged event.
SfTabView tabView = new SfTabView();
tabView.SelectionChanged += TabView_SelectionChanged;
private void TabView_SelectionChanged(object sender, TabSelectionChangedEventArgs e)
{
double newValue = e.NewIndex;
double oldValue = e.OldIndex;
e.Handled = true;
}
SelectionChanging
Occurs when the selection is changing in the SfTabView.
Declaration
public event EventHandler<SelectionChangingEventArgs> SelectionChanging
Event Type
Type |
---|
System.EventHandler<SelectionChangingEventArgs> |
Examples
Here is an example of how to register the SelectionChanging event.
SfTabView tabView = new SfTabView();
tabView.SelectionChanging += TabView_SelectionChanging;
private void TabView_SelectionChanging(object sender, SelectionChangingEventArgs e)
{
var selectionChangingIndex = e.Index;
e.Cancel = true;
}
TabItemTapped
Occurs when the header of the tab item is tapped.
Declaration
public event EventHandler<TabItemTappedEventArgs> TabItemTapped
Event Type
Type |
---|
System.EventHandler<TabItemTappedEventArgs> |
Examples
Here is an example of how to register the TabItemTapped event.
SfTabView tabView = new SfTabView();
tabView.SelectionChanged += TabView_TabItemTapped;
private void TabView_TabItemTapped(object sender, TabItemTappedEventArgs e)
{
e.TabItem.FontSize = 26;
e.Cancel = true;
}