How to get the value of the selected index

Hi,
I work with SyncF. since yesterday. In my project I use a SfSegmentedControl. I want the value of the selected index when is changing. So I declare an Event but I can only get back the SelectedIndex as int and not the value. What is the way ?

Thanx, Q.

3 Replies

DD Devakumar Dhanapoosanam Syncfusion Team April 13, 2020 01:34 PM UTC

Hi Quentin Ruffier des Aimes, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and we would like to let you know that we can achieve your requirement using the SegmentedControl SelectionChanged event to get the current selected SegmentItem value using the Index as per in the below code snippet 
 
XAML: 
<buttons:SfSegmentedControl SelectionChanged="SegmentedControl_SelectionChanged" > 
           ….. 
</buttons:SfSegmentedControl> 
 
 
C#: 
private void SegmentedControl_SelectionChanged(object sender,   
                                       Syncfusion.XForms.Buttons.SelectionChangedEventArgs e) 
{ 
            var segment = sender as SfSegmentedControl; 
            var items = segment.ItemsSource as IList; 
            if(items != null && items.Count > 0) 
            { 
                //Here you can get the selected SegmentItem using the Index 
                var SelectedItem = items[e.Index]; 
            } 
} 
 
 
 
Hope the above solution helps to achieve your requirement. 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D 



QR Quentin Ruffier des Aimes April 13, 2020 01:57 PM UTC

Perfect ! Thx


DD Devakumar Dhanapoosanam Syncfusion Team April 14, 2020 05:19 AM UTC

Hi Quentin Ruffier des Aimes, 
 
We are glad to hear that your requirement has been achieved. 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D

Loader.
Up arrow icon