Mastering Composite Controls in .NET MAUI. Building a TabView from Scratch
There’s no built-in TabView in .NET MAUI, but composition gets you there. Vladislav starts with a small Tab class holding an icon, title, and content, plus a view model with a collection of tabs, then builds the control three ways.
- IndicatorView and CarouselView. The closest to a native tabbed feel. Users can swipe between tabs, and an
IndicatorTemplateturns the indicator dots into icon-and-title headers. - ContentView and RadioButton.
RadioButtoncontrols act as the tab headers, bound toRadioButtonGroup.SelectedValue, and theContentViewswaps in the selected tab’s content. There’s no swiping, but it behaves consistently across platforms. - Stack layouts. A
VerticalStackLayoutcontainer with aHorizontalStackLayoutof headers offers the most control, at the cost of calculating and animating scroll positions yourself.
If you’ve been weighing which approach suits your design, the article includes XAML for each one and a screenshot of the result on Android. The full sample is on GitHub.