Xamarin.Forms Guides | Samples

Xamarin.Forms.Cell Class

Provides base class and capabilities for all Forms cells. Cells are elements meant to be added to ListView or TableView.

See Also: Cell

Syntax

public abstract class Cell : Element, ICellController

Remarks

The subtypes of Cell are:

TypeDescription
EntryCellA Cell with a label and a single line text entry field.
SwitchCellA Cell with a label and an on/off switch.
TextCellA Cell with primary and secondary text.
ImageCellA TextCell that also includes an image.
ViewCellA Cell containing a developer-defined View.

The various subclasses are shown in the following image:

C# Example

Content = new TableView
{
    Root = new TableRoot ("Table Title")
    {
        new TableSection("Section 1 Title")
        {
            new TextCell
            {
                Text = "TextCell Text",
                Detail = "TextCell Detail"
            },
            new ImageCell
            {
                Text = "ImageCell Text",
                Detail = "ImageCell Detail",
                ImageSource = "http://xamarin.com/images/index/ide-xamarin-studio.png"
            },
            new EntryCell
            {
                Label = "EntryCell:",
                Placeholder = "default keyboard",
                Keyboard = Keyboard.Default
            }
        },
        new TableSection("Section 2 Title")
        {
            new EntryCell
            {
                Label = "Another EntryCell:",
                Placeholder = "phone keyboard",
                Keyboard = Keyboard.Telephone
            },
            new SwitchCell
            {
                Text = "SwitchCell:"
            },
            new ViewCell
            {
                View = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = 
                    {
                        new Label
                        {
                            Text = "Custom Slider View:"
                        },
                        new Slider
                        {
                        }
                    }
                }
            }
        }
    }
}

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

PropertyValue
ContextActions

A list of MenuItem objects to display when the user performs the context action.

IsEnabled

true or false, indicating whether the animation for ActivityIndicator is displayed.

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, 1.4.0.0, 1.5.0.0, 2.0.0.0

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

See Also: Element

Protected Constructors

Initializes a new instance of the Cell class.

Public Fields

const
DefaultCellHeightInt32 (40). The default height of cells.
static readonly
IsEnabledPropertyBindableProperty. Identifies the IsEnabled bindable property.

Public Properties

[read-only]
ContextActionsIList<MenuItem>. Gets a list of menu items to display when the user performs the device-specific context gesture on the Cell.
[read-only]
HasContextActionsBoolean. Gets a value that indicates whether the cell has at least one menu item in its Cell.ContextActions list property.
HeightDouble. Gets or sets the height of the Cell.
IsEnabledBoolean. Gets or sets the IsEnabled state of the Cell. This is a bindable property.
[read-only]
RenderHeightDouble. Gets the height of the rendered cell on the device.

Public Methods

ForceUpdateSize()
Immediately updates the cell's size.

Protected Methods

OnAppearing()
Invoked whenever an Cell.Appearing event occurs. Implement this method to add class handling for this event.
override
OnBindingContextChanged()
Event that is raised when the binding context is changed.
OnDisappearing()
Invoked whenever an Cell.Disappearing event occurs. Implement this method to add class handling for this event.
OnLongPressed()
Invoked whenever a long press is applied to the Cell.
override
OnParentSet()
Application developers can override this method to do actions when the cell's parent is set.
override
OnPropertyChanging(String)
TApplication developers can override this method to do actions when the property named by propertyName is set.
OnTapped()
Invoked whenever the Cell is Tapped.

Public Events

AppearingOccurs when the visual representation of the Cell is being added to the visual layout.
DisappearingOccurs when the visual representation of the Cell is being removed from the visual layout.
TappedOccurs when the Cell is Tapped.

Explicitly Implemented Interface Members

Cell$ICellController.SendAppearingThis method is for internal use by platform renderers.
Cell$ICellController.SendDisappearingThis method is for internal use by platform renderers.