menu

Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfSwitch - API Reference

    Show / Hide Table of Contents

    Class SfSwitch

    Represents the SfSwitch class.

    Inheritance
    System.Object
    SfSwitch
    Implements
    System.IDisposable
    Namespace: Syncfusion.XForms.Buttons
    Assembly: Syncfusion.Buttons.XForms.dll
    Syntax
    public class SfSwitch : ContentView, IDisposable, IParentThemeElement, IThemeElement

    Constructors

    SfSwitch()

    Initializes a new instance of the SfSwitch class with default Visual settings and its Visual States.

    Declaration
    public SfSwitch()

    Fields

    AllowIndeterminateStateProperty

    Identifies the AllowIndeterminateState dependency property. This property can be used to enable the inderterminate state of the SfSwitch control.

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

    EnableRippleAnimationProperty

    Identifies the EnableRippleAnimation dependency property. This property can be used to enable the ripple animation of the SfSwitch control.

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

    IsBusyProperty

    Identifies the IsBusy dependency property. This property can be used to enable the busy indicator of the SfSwitch control.

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

    IsOnProperty

    Identifies the IsOn dependency property. This property can be used to enable the switch state of the SfSwitch control.

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

    OrientationProperty

    Identifies the Orientation dependency property. This property can be used to change the orientation of the SfSwitch control.

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

    SwitchSettingsProperty

    Identifies the SwitchSettings dependency property. This property can be used to customize the switch settings of SfSwitch control.

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

    VisualTypeProperty

    Identifies the VisualType dependency property. This property can be used to change the visual tye of the SfSwitch control.

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

    Properties

    AllowIndeterminateState

    Gets or sets a value indicating whether to allow indeterminate state or not. While When setting is this property to false, it moves IsOn to false when it is null. This is a bindable property.

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

    EnableRippleAnimation

    Gets or sets a value indicating whether this property determines ripple animation. This API marked internal, it can be used by reflection if we need any requirement.

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

    IsBusy

    Gets or sets a value indicating whether gets or sets the bool value to show or hide the busy indication on thumb.

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

    IsOn

    Gets or sets the nullable Boolean value that defines the state of the switch, where On is true, Off is false, and indeterminate is null. Also, null value moves to off the Off state when the control is sets AllowIndeterminateState as to false. This is a bindable property.

    Declaration
    public Nullable<bool> IsOn { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Boolean>

    Orientation

    Gets or sets the Syncfusion.XForms.Buttons.SwitchOrientation that defines how the element gets is laid in a layout either horizontally or vertically. This is a bindable property.

    Declaration
    public SwitchOrientation Orientation { get; set; }
    Property Value
    Type Description
    SwitchOrientation

    SwitchSettings

    Gets or sets the Syncfusion.XForms.Buttons. ISwitchSettings that defines how the control should appears as a defined state.Use Visual State Manager to provide desire settings based on states. Switch Settings is only applicable for Custom Visual Type.

    Declaration
    public ISwitchSettings SwitchSettings { get; set; }
    Property Value
    Type Description
    ISwitchSettings

    VisualType

    Gets or sets Syncfusion.XForms.Buttons.VisualType that defines how the control should appear. The control should appear as either default, material, Cupertino, fluent, or Custom.

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

    Methods

    ChangeVisualState()

    Overrides to set our custom VSM to the control.

    Declaration
    protected override void ChangeVisualState()

    Dispose()

    Disposes all objects and events that hooked and clear its visual states.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Dispose the objects.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    Is disposing object.

    OnBindingContextChanged()

    Called when the binding context is changed. XAMARIN-40870 - Binding is not applied for default value at initial loading only.

    Declaration
    protected override void OnBindingContextChanged()

    OnMeasure(Double, Double)

    Overrides to calculate the desire size of the control.

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

    The Width Constraint.

    System.Double heightConstraint

    The Height Constraint.

    Returns
    Type Description
    Xamarin.Forms.SizeRequest

    Returns a value.

    OnPropertyChanged(String)

    Override the Property Changed method.

    Declaration
    protected override void OnPropertyChanged(string propertyName = null)
    Parameters
    Type Name Description
    System.String propertyName

    The Property Name.

    Events

    StateChanged

    It represents the State changed event handler. This changed event is hooked when State changed in SfSwitch control.

    Declaration
    public event EventHandler<SwitchStateChangedEventArgs> StateChanged
    Event Type
    Type Description
    System.EventHandler<SwitchStateChangedEventArgs>

    StateChanging

    It represents the State changing event handler. This changing event is hooked when State move occurred in SfSwitch control.

    Declaration
    public event EventHandler<SwitchStateChangingEventArgs> StateChanging
    Event Type
    Type Description
    System.EventHandler<SwitchStateChangingEventArgs>

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved