See Also: SwitchCell Members
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:
| Property | Value |
|---|---|
| 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. |