ItemsSource using as Object Type not working. used to work for Xamarin.Forms?

Hi, 

below itemsource populating as Object type used to work with Xamarin.forms but i cant make it working same way using Maui. what is the way to achieve this? in the documentation i see samples only for String type


<buttons:SfSegmentedControl
x:Name="viewSegmentControl"
Grid.Row="0"
SelectedIndex="{Binding SelectedViewIndex, Mode=TwoWay}"
SelectionChanged="ViewSegmentControl_SelectionChanged"
Style="{StaticResource SegmentedGenderStyle}">
<buttons:SfSegmentedControl.ItemsSource>
<x:Array Type="{x:Type x:Object}">
<StackLayout HorizontalOptions="Center" Orientation="Horizontal">
<Image
HeightRequest="24"
Source="man.png"
WidthRequest="24" />
<Label
Margin="5,0,0,0"
Text="{resx:Translate Man,
IsUpper=True}"
VerticalOptions="Center" />
</StackLayout>
<StackLayout HorizontalOptions="Center" Orientation="Horizontal">
<Image
HeightRequest="24"
Source="{toolkit:AppThemeResource IconSearch}"
WidthRequest="24" />
<Label
Margin="5,0,0,0"
Text="{resx:Translate Woman,
IsUpper=True}"
VerticalOptions="Center" />
</StackLayout>
</x:Array>
</buttons:SfSegmentedControl.ItemsSource>
</buttons:SfSegmentedControl>

1 Reply

VM Vidyalakshmi Mani Syncfusion Team November 21, 2025 01:55 PM UTC

Hi Emil,


In the .NET MAUI SfSegmentedControl, the ItemsSource collection can be bound to different types such as SfSegmentItem, String, or Int. You can also customize the appearance of each segment using the SegmentTemplate.


Here’s a simple example:

   


<buttons:SfSegmentedControl x:Name="segmentedControl">

        <buttons:SfSegmentedControl.ItemsSource>

            <x:Array Type="{x:Type x:String}">

                <x:String>Day</x:String>

                <x:String>Week</x:String>

                <x:String>Month</x:String>

                <x:String>Year</x:String>

            </x:Array>

        </buttons:SfSegmentedControl.ItemsSource>

        <buttons:SfSegmentedControl.SegmentTemplate>

            <DataTemplate>

                <Grid Background="LightGray">

                    <Label Text="{Binding Text}"

                           TextColor="Red"

                           Margin="6" />

                </Grid>

            </DataTemplate>

        </buttons:SfSegmentedControl.SegmentTemplate>

</buttons:SfSegmentedControl>



This sample demonstrates how you can bind a string collection to the segmented control and apply a custom template to style each segment.


For detailed guidance, check out our UG documentation:


We’ve also prepared a simple sample project to illustrate this feature. Please check the attached sample for reference.


If you need further assistance or have any questions, we’re here to help.


Regards,

Vidyalakshmi M.



Attachment: MauiApp1_a6dd9713.zip

Loader.
Up arrow icon