Xamarin.Forms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfSegmentedControl

    Show / Hide Table of Contents

    Class 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.

    Inheritance
    System.Object
    SfSegmentedControl
    Namespace: Syncfusion.XForms.Buttons
    Assembly: Syncfusion.Buttons.XForms.dll
    Syntax
    public class SfSegmentedControl : View, IParentThemeElement, IThemeElement

    Constructors

    SfSegmentedControl()

    Initializes a new instance of the SfSegmentedControl class. This is a constructor of the SfSegmentedControlclass.

    Declaration
    public SfSegmentedControl()

    Fields

    AutoScrollSelectedItemProperty

    Identifies the AutoScrollSelectedItem bindable property. This property can be used to enable or disable the scrolling when selected index changed in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty AutoScrollSelectedItemProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    BackgroundColorProperty

    Identifies the BackgroundColor bindable property.

    Declaration
    public static readonly BindableProperty BackgroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    BorderColorProperty

    Identifies the BorderColor bindable property. This property can be used to change the color of the border for the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty BorderColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    BorderThicknessProperty

    Identifies the BorderThickness bindable property. This property can be used to change the thickness of the border for the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty BorderThicknessProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ColorProperty

    Identifies the Color bindable property. This property can be used to change the color of segments for the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty ColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    CornerRadiusProperty

    Identifies the CornerRadius bindable property. This property can be used to get the rounded corner for the border of the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty CornerRadiusProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    DisabledTextColorProperty

    Identifies the DisabledTextColor bindable property. This property can be used to change the text color of disabled segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty DisabledTextColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    DisplayModeProperty

    Identifies the DisplayMode bindable property. This property can be used to change the display mode of the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty DisplayModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontAttributesProperty

    Identifies the FontAttributes bindable property. This property can be used to change the attributes for the font of text in segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontAttributesProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontColorProperty

    Identifies the FontColor bindable property. This property can be used to change the foreground color for text of segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontFamilyProperty

    Identifies the FontFamily bindable property. This property can be used to change the font family of the text of segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontFamilyProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontIconFontColorProperty

    Identifies the FontIconFontColor bindable property. This property can be used to change the foreground color for icons in segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontIconFontColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontIconFontFamilyProperty

    Identifies the FontIconFontFamily bindable property. This property can be used to change the font family for the icons in segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontIconFontFamilyProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontIconFontSizeProperty

    Identifies the FontIconFontSize bindable property. This property can be used to change the size of icons in segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontIconFontSizeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FontSizeProperty

    Identifies the FontSize bindable property. This property can be used to change the attributes for the font of text in segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty FontSizeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ItemsSourceProperty

    Identifies the ItemsSource bindable property.

    Declaration
    public static readonly BindableProperty ItemsSourceProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ScrollToPositionProperty

    Identifies the ScrollToPosition bindable property.

    Declaration
    public static readonly BindableProperty ScrollToPositionProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentBackgroundColorProperty

    Identifies the SegmentBackgroundColor bindable property. This property can be used to change the background of segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentBackgroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentBorderColorProperty

    Identifies the SegmentBorderColor bindable property. This property can be used to change the color for border between segment items in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentBorderColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentBorderThicknessProperty

    Identifies the SegmentBorderThickness bindable property. This property can be used to change the thickness for segment border in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentBorderThicknessProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentCornerRadiusProperty

    Identifies the SegmentCornerRadius bindable property. This property can be used to change the corner radius value for the segment items available in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentCornerRadiusProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentHeightProperty

    Identifies the SegmentHeight bindable property. This property can be used to customize the height of the segments in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentHeightProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentPaddingProperty

    Identifies the SegmentPadding bindable property. This property can be used to change the padding for segment in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentPaddingProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SegmentWidthProperty

    Identifies the SegmentWidth bindable property. This property can be used to customize the width of the segments in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SegmentWidthProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectedIndexProperty

    Identifies the SelectedIndex bindable property. This property can be used to change the index of the selected item of the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SelectedIndexProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionAnimationDurationProperty

    Identifies the SelectionAnimationDuration bindable property. This property can be used to change padding for segments in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SelectionAnimationDurationProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionIndicatorSettingsProperty

    Identifies the SelectionIndicatorSettings bindable property. This property can be used to customaize the selection indicator of SelectionIndicatorSettings.

    Declaration
    public static readonly BindableProperty SelectionIndicatorSettingsProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionTextColorProperty

    Identifies the SelectionTextColor bindable property. This property can be used to change the text color of the selected segment in the SfSegmentedControl.

    Declaration
    public static readonly BindableProperty SelectionTextColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    VisibleSegmentsCountProperty

    Identifies the VisibleSegmentsCount bindable property. This property can be used to show the segment items based on the VisibleSegmentCount.

    Declaration
    public static readonly BindableProperty VisibleSegmentsCountProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    Properties

    AutoScrollSelectedItem

    Gets or sets a value indicating whether to enable the auto scrolling when selected index is changed in SfSegmentedControl.

    Declaration
    public bool AutoScrollSelectedItem { get; set; }
    Property Value
    Type Description
    System.Boolean

    BackgroundColor

    Gets or sets the color of segments for SfSegmentedControl.

    Declaration
    public Color BackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    BorderColor

    Gets or sets the value of BorderColor. This property can be used to change the color of the border for the SfSegmentedControl.

    Declaration
    public Color BorderColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    BorderThickness

    Gets or sets the value of the BorderThickness. This property can be used to change the thickness of the border for the SfSegmentedControl.

    Declaration
    public double BorderThickness { get; set; }
    Property Value
    Type Description
    System.Double

    Color

    Gets or sets the value of Color. This property can be used to change the color of segments for the SfSegmentedControl.

    Declaration
    public Color Color { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    CornerRadius

    Gets or sets the corner radius value for the border of the SfSegmentedControl. This CornerRadius property is used when drawing rounded corners.

    Declaration
    public double CornerRadius { get; set; }
    Property Value
    Type Description
    System.Double

    DisabledTextColor

    Gets or sets the value of DisabledTextColor. This property can be used to change the text color of disabled segment items in the SfSegmentedControl.

    Declaration
    public Color DisabledTextColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    DisplayMode

    Gets or sets the value of type SegmentDisplayMode to define the display mode of the SfSegmentedControl. Default value is Text.

    Declaration
    public SegmentDisplayMode DisplayMode { get; set; }
    Property Value
    Type Description
    SegmentDisplayMode

    FontAttributes

    Gets or sets the value of FontAttributes. This property can be used to change the attributes for the font of text in the segment items in the SfSegmentedControl.

    Declaration
    public FontAttributes FontAttributes { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.FontAttributes

    FontColor

    Gets or sets the value of FontColor. This property can be used to change the foreground color for text of segment items in the SfSegmentedControl.

    Declaration
    public Color FontColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    FontFamily

    Gets or sets the value of FontFamily. This property can be used to change the font family of the text of segment items in the SfSegmentedControl.

    Declaration
    public string FontFamily { get; set; }
    Property Value
    Type Description
    System.String

    FontIconFontColor

    Gets or sets the value of FontIconFontColor. This property can be used to change the foreground color for icons in segment items in the SfSegmentedControl.

    Declaration
    public Color FontIconFontColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    FontIconFontFamily

    Gets or sets the value of FontIconFontFamily. This property can be used to change the font family for the icons in segment items in the SfSegmentedControl.

    Declaration
    public string FontIconFontFamily { get; set; }
    Property Value
    Type Description
    System.String

    FontIconFontSize

    Gets or sets the value of FontIconFontSize. This property can be used to change the size of icons in segment items in the SfSegmentedControl.

    Declaration
    public double FontIconFontSize { get; set; }
    Property Value
    Type Description
    System.Double

    FontSize

    Gets or sets the value of FontSize. This property can be used to change the font size for the text of segment items and change the attributes for the font of text in segment items in the SfSegmentedControl.

    Declaration
    public double FontSize { get; set; }
    Property Value
    Type Description
    System.Double

    ItemsSource

    Gets or sets children for SfSegmentedControl through the collection of SfSegmentItem or collection of strings or views.

    Declaration
    public IEnumerable ItemsSource { get; set; }
    Property Value
    Type Description
    System.Collections.IEnumerable

    ScrollToPosition

    Gets or sets a value for positioning the selected index at a specific position when AutoScrollSelectedItem is set to true.

    Declaration
    public ScrollToPosition ScrollToPosition { get; set; }
    Property Value
    Type Description
    ScrollToPosition

    SegmentBackgroundColor

    Gets or sets the value of the background color for the segment items in the SfSegmentedControl.

    Declaration
    public Color SegmentBackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    SegmentBorderColor

    Gets or sets the value of SegmentBorderColor. This property can be used to change the color for border between segment items in the SfSegmentedControl.

    Declaration
    public Color SegmentBorderColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    SegmentBorderThickness

    Gets or sets the value of SegmentBorderThickness. This property can be used to change the thickness for segment border in the SfSegmentedControl.

    Declaration
    public double SegmentBorderThickness { get; set; }
    Property Value
    Type Description
    System.Double

    SegmentCornerRadius

    Gets or sets the corner radius value for the segment items available in SfSegmentedControl.

    Declaration
    public double SegmentCornerRadius { get; set; }
    Property Value
    Type Description
    System.Double

    SegmentHeight

    Gets or sets the value of the SegmentHeight. This property can be used to customize the height of the segments in the SfSegmentedControl.

    Declaration
    public double SegmentHeight { get; set; }
    Property Value
    Type Description
    System.Double

    SegmentPadding

    Gets or sets the value of SegmentPadding. This property can be used to change the padding for segments in the SfSegmentedControl.

    Declaration
    public double SegmentPadding { get; set; }
    Property Value
    Type Description
    System.Double

    SegmentWidth

    Gets or sets the value of the SegmentWidth. This property can be used to customize the width of the segments in the SfSegmentedControl.

    Declaration
    public double SegmentWidth { get; set; }
    Property Value
    Type Description
    System.Double

    SelectedIndex

    Gets or sets the value of SelectedIndex. This property can be used to change the index of the selected item of the SfSegmentedControl.

    Declaration
    public int SelectedIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    SelectionAnimationDuration

    Gets or sets the duration for the animation of selection strip SfSegmentedControl.

    Declaration
    public double SelectionAnimationDuration { get; set; }
    Property Value
    Type Description
    System.Double

    SelectionIndicatorSettings

    Gets or sets value of type SelectionIndicatorSettings to cusomize the selection indicator of SelectionIndicatorSettings, Selection indicator is a strip indicating the selected item of SfSegmentedControl.

    Declaration
    public SelectionIndicatorSettings SelectionIndicatorSettings { get; set; }
    Property Value
    Type Description
    SelectionIndicatorSettings

    SelectionTextColor

    Gets or sets the value of SelectionTextColor. This property can be used to change the text color of the selected segment in the SfSegmentedControl.

    Declaration
    public Color SelectionTextColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color

    VisibleSegmentsCount

    Gets or sets a value to show the segments in available space in the SfSegmentedControl.

    Declaration
    public Nullable<int> VisibleSegmentsCount { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Int32>

    Methods

    OnBindingContextChanged()

    Set children BindingContext when SfSegmentedControl BindingContext changed.

    Declaration
    protected override void OnBindingContextChanged()

    OnMeasure(Double, Double)

    On the base OnMeasure and returns SizeRequest based on the Parent.

    Declaration
    protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
    Parameters
    Type Name Description
    System.Double widthConstraint

    Width constraint.

    System.Double heightConstraint

    Height constraint.

    Returns
    Type Description
    Xamarin.Forms.SizeRequest

    The measure.

    OnParentSet()

    On Parent set.

    Declaration
    protected override void OnParentSet()

    OnSizeAllocated(Double, Double)

    Ons the size allocated.

    Declaration
    protected override void OnSizeAllocated(double width, double height)
    Parameters
    Type Name Description
    System.Double width

    It is actual Width of control.

    System.Double height

    It is actual Height of control.

    ScrollTo(Int32, ScrollToPosition)

    Scroll the segment item based on the given index and ScrollToPosition.

    Declaration
    public void ScrollTo(int index, ScrollToPosition scrollToPosition)
    Parameters
    Type Name Description
    System.Int32 index

    Index.

    ScrollToPosition scrollToPosition

    Scroll to position.

    ScrollTo(Object, ScrollToPosition)

    Scroll to the segment item based on the provided segment item and Xamarin.Forms.ScrollToPosition.

    Declaration
    public void ScrollTo(object item, ScrollToPosition scrollToPosition)
    Parameters
    Type Name Description
    System.Object item

    Item.

    ScrollToPosition scrollToPosition

    Scroll to position.

    Events

    SelectionChanged

    The SelectionChanged event is hooked when the selected index of the SfSegmentedControl is changed.

    Declaration
    public event EventHandler<SelectionChangedEventArgs> SelectionChanged
    Event Type
    Type Description
    System.EventHandler<SelectionChangedEventArgs>
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved