Xamarin.Forms.SwitchCell Class
A Xamarin.Forms.Cell with a label and an on/off switch.

See Also: SwitchCell Members

Syntax

public class SwitchCell : Cell

Remarks

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",
                Font = Font.BoldSystemFontOfSize(50),
                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 =
                {
                    header,
                    tableView
                }
            };
        }
    }
}

The Xamarin.Forms.SwitchCell class has the following XAML properties:

PropertyValue
On

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

OnChanged

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

Text

Text that represents the title of the switch cell.

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0