Xamarin.Forms Guides | Samples

Xamarin.Forms.SwitchCell Class

A Cell with a label and an on/off switch.

See Also: SwitchCell


public class SwitchCell : Cell


The following example shows a basic use.

C# Example

using System;
using Xamarin.Forms;

namespace FormsGallery
    class SwitchCellDemoPage : ContentPage
        public SwitchCellDemoPage()
            Label header = new Label
                Text = "SwitchCell",
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center

            TableView tableView = new TableView
                Intent = TableIntent.Form,
                Root = new TableRoot
                    new TableSection
                        new SwitchCell
                            Text = "SwitchCell:"

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
                Children =

XAML for Xamarin.Forms supports the following properties for the SwitchCell class:


true or false, to indicate whether the switch cell is in the "on" position.


The name of an event handler. Note that this tag must appear below On.


Text that represents the title of the switch cell.


Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions:,,,,,,

The members of Xamarin.Forms.SwitchCell are listed below.

See Also: Cell

Public Constructors

Initializes a new instance of the SwitchCell class.

Public Fields

static readonly
OnPropertyBindableProperty. Identifies the SwitchCell.On bindable property.
static readonly
TextPropertyBindableProperty. Identifies the Text bindable property.

Public Properties

OnBoolean. Gets or sets the state of the switch. This is a bindable property.
TextString. Gets or sets the text displayed next to the switch. This is a bindable property.

Public Events

OnChangedTriggered when the switch has changed value.