You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can have tabs using Shell. However, what happens if we want to have nested tabs within a specific section (Example: Grid)?, what if we want to fully customize each tab?. In these cases, we would need a Custom Renderer so far...
The TabView is a way to display a set of tabs and their respective content. TabView is useful for displaying several content while giving a user the capability to customize mostly everything.
NOTE: TabView is a cross-platform view that takes over when native tabs hit their limits, such as positioning with layouts, styling, and non-uniform styling like a raised button.
API
Next, a list with the TabView properties, events and visualstates.
Properties
TabView Properties
Property
Type
Description
TabItemsSource
IEnumerable
A collection used to generate the TabView's tab items.
TabViewItemDataTemplate
DataTemplate
the template the Tab View uses to generate tab items' header.
TabContentDataTemplate
DataTemplate
The template the Tab View uses to generate tab items' content.
IsCyclical
Bool
Enable or disable cyclical tabs navigation.
IsLazy
Bool
Enable or disable lazy tabs loading.
SelectedIndex
Int
Gets or sets the currently selected tab. Default is 0.
TabStripPlacement
TabStripPlacement
The TabStrip placement (top or bottom).
TabStripBackground
Brush
The TabStrip background.
TabIndicatorBrush
Brush
The TabIndicator background.
TabIndicatorHeight
double
The TabIndicator height.
TabIndicatorWidth
double
The TabIndicator width.
TabIndicatorPlacement
TabIndicatorPlacement
TabIndicatorView
View
The TabIndicator content.
TabContentBackground
Brush
The tab content background.
TabContentHeight
Double
The tab content height.
TabStripHeight
Double
The TabStrip height.
TabContentHeight
Double
The tab content height.
HasTabStripShadow
Bool
Show or hide the TabStrip shadow effect.
IsTabTransitionEnabled
Bool
Enable or disable the transition between tabs.
IsSwipeEnabled
Bool
Enable or disable the swipe gesture.
TabViewItem Properties
Property
Type
Description
Text
String
The text of the tab.
TextColor
Color
The text color of the tab.
TextColorSelected
Color
The text color of the selected tab.
FontSize
FontSize
The font size used in the tab text.
FontSizeSelected
FontSize
The font size used in the selected tab.
FontFamily
String
The font family used in the tab.
FontFamilySelected
String
The font family used in the selected tab.
FontAttributes
FontAttributes
The font attributes used in the tab.
FontAttributesSelected
FontAttributes
The font attributes used in the selected tab.
Icon
ImageSource
The icon of the tab.
IconSelected
ImageSource
The ImageSource used as icon in the selected tab.
Content
View
The content of the tab. Is View, can use anything as content.
BadgeText
Bool
The badge text used in the tab.
BadgeTextColor
Color
The badge text color used in the tab.
BadgeTextColorSelected
Color
The badge text color used in the selected tab.
BadgeBackgroundColor
Color
The badge color used in the tab.
BadgeBackgroundColorSelected
Color
The badge color used in the selected tab.
IsSelected
Bool
a bool that indicate if the tab is selected or not.
TapCommand
ICommand
Command that is executed when the user tap a tab.
TapCommandParameter
object
The tap command parameter.
Events
TabView Events
Event
Description
SelectionChanged
Event that is raised when the selected tab changed.
Scrolled
Event that is raised when is swiping between tabs.
TabViewItem Events
Event
Description
TabTapped
Event that is raised when the user tap a tab.
VisualStates
The Visual State Manager (VSM) provides a structured way to make visual changes to the user interface from code.
The VSM introduces the concept of visual states. TabView can have several different visual appearances depending on its underlying state.
Do you want to navigate between the tabs cyclically?
<TabView
IsCyclical="True">
...
</TabView>
Lazy Loading
Lazy tab loading:
<TabView
IsLazy="True">
...
</TabView>
Tab Transitions and TabViewItem animations
Can use Maui animations to customize the transition between each tab, animate the tab when appears or disappears, or even animate the badge when appears or disappears.
TabView
We can have tabs using Shell. However, what happens if we want to have nested tabs within a specific section (Example: Grid)?, what if we want to fully customize each tab?. In these cases, we would need a Custom Renderer so far...
The TabView is a way to display a set of tabs and their respective content. TabView is useful for displaying several content while giving a user the capability to customize mostly everything.
NOTE: TabView is a cross-platform view that takes over when native tabs hit their limits, such as positioning with layouts, styling, and non-uniform styling like a raised button.
API
Next, a list with the TabView properties, events and visualstates.
Properties
TabView Properties
TabViewItem Properties
Events
TabView Events
TabViewItem Events
VisualStates
The Visual State Manager (VSM) provides a structured way to make visual changes to the user interface from code.
The VSM introduces the concept of visual states. TabView can have several different visual appearances depending on its underlying state.
TabView have four specific VisualStates:
Scenarios
Let's see some samples covering common scenarios.
Basic Tabs
Let's see a basic example:
TabItemsSource
Using TabItemsSource (dynamic tabs):
Custom Tabs
The appearance of each tab can be customized:
Cyclical Tabs
Do you want to navigate between the tabs cyclically?
Lazy Loading
Lazy tab loading:
Tab Transitions and TabViewItem animations
Can use Maui animations to customize the transition between each tab, animate the tab when appears or disappears, or even animate the badge when appears or disappears.
Using VisualStates
Can use different visual states to customize the current tab, the next tab, etc.
Create Tabs using C#
You can use XAML or C# to create the UI in Maui. Let's see how we would create tabs using C#.
Using Styles
Can customize the appearance of the tab content, tab strip, tab item, etc. using XAML styles or CSS.
Using XAML:
Using CSS:
Difficulty : Medium
The text was updated successfully, but these errors were encountered: