Home

Awesome

SegmentedControl for .NET MAUI

Version Downloads

This library provides a segmented control for .NET MAUI apps using native platform APIs.

Download and Install Plugin.SegmentedControl.Maui

This library is available on NuGet: Plugin.SegmentedControl.Maui
Use the following command to install Plugin.SegmentedControl.Maui using the NuGet package manager console:

PM> Install-Package Plugin.SegmentedControl.Maui

You can use this library in any .NET MAUI project compatible with .NET 8 and higher.

App Setup

This plugin provides an extension method for MauiAppBuilder called UseSegmentedControl, which ensures proper startup and initialization.
Call this method within your MauiProgram just as demonstrated in the SegmentedControlDemoApp:

var builder = MauiApp.CreateBuilder()
    .UseMauiApp<App>()
    .UseSegmentedControl();

API Usage

The SegmentedControl class provides several properties to customize its behavior and appearance. Below is a table detailing each property and its purpose.

PropertiesDescription
AutoDisconnectHandlerIndicates whether the platform handler disconnects automatically. Default is true.
ChildrenA list of SegmentedControlOption objects representing each segment.
ItemsSourceThe source of data for generating segments.
TextPropertyNameThe name of the property to use for the segment's text when using a non-string ItemsSource.
TextColorThe color of the segment text. Default is Colors.Black.
TintColorThe color used to tint the control. Default is Colors.Blue.
SelectedTextColorThe color of the selected segment's text. Default is Colors.White.
DisabledBackgroundColorThe background color of the control when disabled. Default is Colors.Gray.
DisabledTintColorThe tint color of the control when disabled. Default is Colors.Gray.
DisabledTextColorThe text color of the segments when the control is disabled. Default is Colors.Gray.
DisabledSelectedTextColorThe text color of the selected segment when the control is disabled. Default is Colors.LightGray.
BorderColorThe color of the control's border. Defaults to the value of TintColor.
BorderWidthThe width of the control's border. Varies by platform; 1.0 on Android and 0.0 on others.
SelectedSegmentThe index of the currently selected segment. Default is 0.
SelectedItemThe currently selected item from the ItemsSource.
SegmentSelectedCommandCommand that is executed when a segment is selected.
SegmentSelectedCommandParameterParameter passed to the SegmentSelectedCommand.
FontSizeThe size of the font used for the segment text.
FontFamilyThe font family used for the segment text.
FontAttributesFont attributes for the segment text, such as bold or italic.

Contribution

Contributors welcome! If you find a bug or want to propose a new feature, feel free to do so by opening a new issue on GitHub.

Links