To make the migration from the Xamarin SfSegmented Control to the .NET MAUI SfSegmented Control easier, most of the APIs from the Xamarin SfSegmented Control
were kept in the .NET MAUI SfSegmented Control
. However, to maintain the consistency of API naming in the .NET MAUI SfSegmented Control
, some of the APIs have been renamed. Please find the difference in the following topics.
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Syncfusion.Xamarin.Buttons
Syncfusion.Maui.Buttons
To initialize the control, import the segmented control namespace and initialize the SfSegmentedControl as shown in the following code sample.
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
<ContentPage
...
xmlns:buttons= "clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms" >
<buttons:SfSegmentedControl x:Name= "segmentedControl" />
</ContentPage>
using Syncfusion.XForms.Buttons ;
...
SfSegmentedControl segmentedControl = new SfSegmentedControl ();
this . Content = segmentedControl ;
<ContentPage
...
xmlns:buttons= "clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" >
<buttons:SfSegmentedControl x:Name= "segmentedControl" />
</ContentPage>
using Syncfusion.Maui.Buttons ;
…
SfSegmentedControl segmentedControl = new SfSegmentedControl ();
this . Content = segmentedControl ;
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Description
SfSegmentedControl
SfSegmentedControl
The SegmentedControl allows users explore and switch among different views. It provides a simple way to choose from a linear set of two or more segments, each of which functions as a mutually exclusive button.
SfSegmentItem
SfSegmentItem
Represents a single element in SfSegmentedControl control. It contains the properties to configure title and content region.
SelectionIndicatorSettings
SelectionIndicatorSettings
Provides a set of properties to customize the selection indicator in the SfSegmentedControl control.
Nil
SegmentTextStyle
Gets or sets properties which allows to customize the segment item text style of the SfSegmentedControl.
<ContentPage
xmlns:local= "clr-namespace:SfSegmentSample"
xmlns:buttons= "clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" >
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<buttons:SfSegmentedControl x:Name= "segmentedControl"
SelectedIndex= "1"
VisibleSegmentsCount= "4"
ItemsSource= "{Binding SegmentItems}" >
</buttons:SfSegmentedControl>
</ContentPage>
using Syncfusion.Maui.Buttons ;
. . .
ViewModel viewModel = new ViewModel ();
SfSegmentedControl segmentedControl = new SfSegmentedControl ();
segmentedControl . SelectedIndex = 1 ;
segmentedControl . VisibleSegmentsCount = 4 ;
segmentedControl . ItemsSource = viewModel . SegmentItems ;
this . Content = segmentedControl ;
public class ViewModel
{
private List < SfSegmentItem > segmentItems ;
public ViewModel ()
{
segmentItems = new List < SfSegmentItem >()
{
new SfSegmentItem () { Text = "Day" },
new SfSegmentItem () { Text = "Week" },
new SfSegmentItem () { Text = "Month" },
new SfSegmentItem () { Text = "Year" },
};
}
public List < SfSegmentItem > SegmentItems
{
get { return segmentItems ; }
set { segmentItems = value ; }
}
}
SfSegmentItem
<ContentPage
xmlns:local= "clr-namespace:SfSegmentSample"
xmlns:buttons= "clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" >
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<buttons:SfSegmentedControl x:Name= "segmentedControl"
ItemsSource= "{Binding SegmentItems}" >
<buttons:SfSegmentedControl.SelectionIndicatorSettings>
<buttons:SelectionIndicatorSettings SelectionIndicatorPlacement= "Border"
Background= "#6200EE" />
</buttons:SfSegmentedControl.SelectionIndicatorSettings>
</buttons:SfSegmentedControl>
</ContentPage>
using Syncfusion.Maui.Buttons ;
. . .
ViewModel viewModel = new ViewModel ();
SfSegmentedControl segmentedControl = new SfSegmentedControl ();
segmentedControl . ItemsSource = viewModel . SegmentItems ;
segmentedControl . SelectionIndicatorSettings = new SelectionIndicatorSettings ()
{
SelectionIndicatorPlacement = SelectionIndicatorPlacement . Border ,
Background = Colors . Transparent ,
};
this . Content = segmentedControl ;
public class ViewModel
{
private List < SfSegmentItem > segmentItems ;
public ViewModel ()
{
segmentItems = new List < SfSegmentItem >()
{
new SfSegmentItem () { Text = "Day" },
new SfSegmentItem () { Text = "Week" },
new SfSegmentItem () { Text = "Month" },
new SfSegmentItem () { Text = "Year" },
};
}
public List < SfSegmentItem > SegmentItems
{
get { return segmentItems ; }
set { segmentItems = value ; }
}
}
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Description
Color
Background
Gets or sets the background brush for the selection indicator in the SfSegmentedControl.
Nil
TextColor
Gets or sets the text color for the selection indicator in the SfSegmentedControl.
Nil
Stroke
Gets or sets the stroke color for the selection indicator in the SfSegmentedControl.
Position
SelectionIndicatorPlacement
Gets or sets the selection mode for the selection indicator in the SfSegmentedControl.
BorderThickness
StrokeThickness
Gets or sets the stroke thickness for the selection indicator in the SfSegmentedControl.
The FontColor
, FontSize
, FontFamily
, and FontAttributes
properties of the SfSegmentedControl is grouped to SegmentTextStyle .
<ContentPage
xmlns:local= "clr-namespace:SfSegmentSample"
xmlns:buttons= "clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" >
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<buttons:SfSegmentedControl x:Name= "segmentedControl"
ItemsSource= "{Binding SegmentItems}" >
<buttons:SfSegmentedControl.TextStyle>
<buttons:SegmentTextStyle FontSize= "14" FontFamily= "Roboto" />
</buttons:SfSegmentedControl.TextStyle>
</buttons:SfSegmentedControl>
</ContentPage>
using Syncfusion.Maui.Buttons ;
. . .
ViewModel viewModel = new ViewModel ();
SfSegmentedControl segmentedControl = new SfSegmentedControl ();
segmentedControl . ItemsSource = viewModel . SegmentItems ;
segmentedControl . TextStyle = new SegmentTextStyle ()
{
FontSize = 14 ,
FontFamily = "Roboto" ,
};
this . Content = segmentedControl ;
public class ViewModel
{
private List < SfSegmentItem > segmentItems ;
public ViewModel ()
{
segmentItems = new List < SfSegmentItem >()
{
new SfSegmentItem () { Text = "Day" },
new SfSegmentItem () { Text = "Week" },
new SfSegmentItem () { Text = "Month" },
new SfSegmentItem () { Text = "Year" },
};
}
public List < SfSegmentItem > SegmentItems
{
get { return segmentItems ; }
set { segmentItems = value ; }
}
}
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Description
FontColor
TextColor
Gets or sets the text color for the SfSegmentedControl.
FontSize
FontSize
Gets or sets the double value that represents the font size of the SfSegmentedControl.
FontFamily
FontFamily
Gets or sets the string, that represents font family of the SfSegmentedControl.
FontAttributes
FontAttributes
Gets or sets the FontAttributes of the SfSegmentedControl.
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Description
SelectionChanged
SelectionChanged
Occurs when the selection within the segment item is changed.
Expand Table
Xamarin SfSegmented control
.NET MAUI SfSegmented control
Description
ScrollTo
ScrollTo
Method to scroll the scroll viewer to the specified index.
Nil
SetSegmentEnabled
Sets the enabled state of a specific segment at the specified index.
Multi selection for segment items.