SegmentedControl - AutoScrollSelectedItem

Hi,

I have an app with segmented control - it contains many items. My requirement is that I want to open a page from another page and select a specific item at SegmentedControl (by parameter at page constructor). Select item works fine, but not working AutoScrollSelectedItem property (segmented control does not scroll to position). But if I choose item (for example for picker or button) on the same page than AutoScroll works perfectly.

<buttons:SfSegmentedControl x:Name="sclist" VisibleSegmentsCount="3" Color="Transparent" BackgroundColor="Blue" AutoScrollSelectedItem="True" ScrollToPosition="Center" SelectionTextColor="White" SegmentHeight="35" FontColor="LightGray" HeightRequest="35" MinimumWidthRequest="60" SegmentPadding="0" BorderThickness="0" FontAttributes="Bold" MinimumHeightRequest="20" Margin="0" CornerRadius="0" DisplayMode="Text" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" SelectionChanged="SegmentedControl_SelectionChanged" >
    <buttons:SfSegmentedControl.SelectionIndicatorSettings>
       <buttons:SelectionIndicatorSettings Position="Bottom" Color="Gray" StrokeThickness="4" >
       </buttons:SelectionIndicatorSettings>
      </buttons:SfSegmentedControl.SelectionIndicatorSettings>
</buttons:SfSegmentedControl>



3 Replies

DD Devakumar Dhanapoosanam Syncfusion Team May 29, 2020 06:18 AM UTC

Hi Tomas Turek, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and we would like to let you know that we can resolve this in UWP by applying the segmented control SelectedIndex in the OnAppearing override method instead of setting in the page constructor or by using the ScrollTo method of segmented control as in the below code snippet, 
 
XAML: 
<buttons:SfSegmentedControl x:Name="sclist"  
                            ItemsSource="{Binding SegmentItems}" 
                            VisibleSegmentsCount="3" Color="Transparent"  
                            BackgroundColor="Blue" AutoScrollSelectedItem="True"  
                            ScrollToPosition="Center" SelectionTextColor="White" > 
 
</buttons:SfSegmentedControl> 
 
C#: 
 
protected override void OnAppearing() 
{ 
       base.OnAppearing(); 
       sclist.ScrollTo(sclist.SelectedIndex, Syncfusion.XForms.Buttons.ScrollToPosition.Center); 
} 
 
 
 
Please check whether the above solution works for your requirement or not. Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D 



TT Tomas Turek June 2, 2020 07:35 AM UTC

It works perfectly. Thank you


DD Devakumar Dhanapoosanam Syncfusion Team June 3, 2020 06:59 AM UTC

Hi Tomas Turek, 
 
Thanks for your update. We are glad to hear that given solution works. 
 
Please let us know if you need any further assistance. 
 
Regards, 
Devakumar D 


Loader.
Up arrow icon