Xamarin.Forms Guides | Samples

Xamarin.Forms Namespace

Cross-platform, natively-backed UI toolkit.


Xamarin.Forms is a cross-platform, natively-backed UI toolkit abstraction that allows developers to create user interfaces that can be shared across Android, iOS, and Windows Phone. Because the user interfaces use the native controls of the target platforms, they have the appearance and, importantly, the responsiveness of natively built apps.

Hello, Xamarin.Forms!

The user-experience of a Xamarin.Forms application is usually defined in a cross-platform shared project (either a Portable Class Library or a Shared Project) and combined with platform-specific projects that, at the least, initialize the native platform rendering (note the call to Forms.Init() in the platform code samples below) and, more generally, extend the user-experience and user-interface in platform-specific manners (for instance, by accessing platform-specific sensors or capabilities).

The dependencies are one-way: the platforms depend on the shared project, but not vice-versa:

The Solution Explorer for a cross-platform "Hello, World!" app might look like this:

The shared portion of the Xamarin.Forms code might look like this:

C# Example

public class App : Xamarin.Forms.Application
    public App ()
        MainPage = new ContentPage
            Content = new Label
                    Text = "Hello, Forms !",
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,

The iOS platform code would look like this:

C# Example

public class AppDelegate : FormsApplicationDelegate
    UIWindow window;

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)

        LoadApplication (new App ());

        return base.FinishedLaunching (app, options);

The Android platform code would look like this:

C# Example

[Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true)]
public class MainActivity : FormsApplicationActivity
    protected override void OnCreate(Bundle bundle)

        Forms.Init(this, bundle);

        LoadApplication (new App ());

And the Windows Phone code would look like this:

C# Example

public partial class MainPage 
    public MainPage()


        LoadApplication (new HelloXamarinFormsWorld.App ());

The resulting app looks like this on the various devices:

Elements in Xamarin.Forms

Important types in the Xamarin.Forms namespace include Page, View, and Layout. Pages typically correspond with controller objects (Activities in the Android world, UIViewControllers in the iOS world), Views with controls or widgets, and Layouts arrange Views on other Views. These types are all derived from Element.

Model-View-ViewModel and Xamarin.Forms

Application developers use the Model-View-ViewModel (MVVM) pattern to create Xamarin.Forms apps that cleanly separate the concerns of data presentation and user interface from the concerns of data storage and manipulation. The Xamarin.Forms framework enables this by providing, among a few other related types, the BindableObject and BindableProperty classes. Objects that inherit from BindableObject can be bound to members of type BindableProperty on other objects.

A BindableObject maintains dictionary of BindableProperty names and an association with their corresponding binding contexts--simply the object on which the BindableProperty is defined and that the application developer has assigned to the BindingObject.BindingContext property--through a Binding. See BindableObject for more information.


AbsoluteLayoutPositions child elements at absolute positions.
AbsoluteLayout+IAbsoluteList<T>List interface with overloads for adding elements to an absolute layout.
AbsoluteLayoutFlagsFlags used to modify how layout bounds are interpreted in an AbsoluteLayout.
ActivityIndicatorA visual control used to indicate that something is ongoing.
AnimationEncapsulates an animation, a collection of functions that modify properties over a user-perceptible time period.
AnimationExtensionsExtension methods for Animation.
ApplicationClass that represents a cross-platform mobile application.
AppLinkEntryA deep application link in an app link search index.
AspectDefines how an image is displayed.
BackButtonPressedEventArgsInternal use only. Contains arguments for the event that is raised when a back button is pressed.
BaseMenuItemBase class for menu items.
BehaviorBase class for generalized user-defined behaviors that can respond to arbitrary conditions and events.
Behavior<T>Base generic class for generalized user-defined behaviors that can respond to arbitrary conditions and events.
BindableObjectProvides a mechanism by which application developers can propagate changes that are made to data in one object to another, by enabling validation, type coercion, and an event system. BindableProperty.
BindableObjectExtensionsContains convenience extension methods for BindableObject.
BindablePropertyA BindableProperty is a backing store for properties allowing bindings on BindableObject.
BindableProperty+BindingPropertyChangedDelegateDelegate for BindableProperty.PropertyChanged.
BindableProperty+BindingPropertyChangedDelegate<TPropertyType>Strongly-typed delegate for BindableProperty.PropertyChanged.
BindableProperty+BindingPropertyChangingDelegateDelegate for BindableProperty.PropertyChanging.
BindableProperty+BindingPropertyChangingDelegate<TPropertyType>Strongly-typed delegate for BindableProperty.PropertyChanging.
BindableProperty+CoerceValueDelegateDelegate for BindableProperty.CoerceValue.
BindableProperty+CoerceValueDelegate<TPropertyType>Strongly-typed delegate for BindableProperty.CoerceValue.
BindableProperty+CreateDefaultValueDelegateStrongly typed delegate for BindableProperty.DefaultValueCreator.
BindableProperty+CreateDefaultValueDelegate<TDeclarer,TPropertyType>Delegate for BindableProperty.DefaultValueCreator.
BindableProperty+ValidateValueDelegateDelegate for BindableProperty.ValidateValue.
BindableProperty+ValidateValueDelegate<TPropertyType>Strongly-typed delegate for BindableProperty.ValidateValue.
BindablePropertyConverterA TypeConverter for bindable properties.
BindablePropertyKeyThe secret key to a BindableProperty, used to implement a BindableProperty with restricted write access.
BindingA single 1:1 immutable data binding.
BindingBaseAn abstract class that provides a BindingMode and a formatting option.
BindingConditionClass that represents a value comparison with the target of an arbitrary binding.
BindingModeThe direction of changes propagation for bindings.
BindingTypeConverterType converter that converts from source types to Binding
BoundsConstraintA bounds layout constraint used by RelativeLayouts.
BoundsTypeConverterA TypeConverter that converts strings into Rectangles for use with AbsoluteLayouts.
BoxViewA View used to draw a solid colored rectangle.
ButtonA button View that reacts to touch events.
Button+ButtonContentLayoutControls the relative positioning of, and spacing between, text and an image on a Button.
Button+ButtonContentLayout+ImagePositionEnumerates image locations within a button.
Button+ButtonContentTypeConverterClass that the XAML parser uses to convert strings to Button+ButtonContentLayout objects.
CarouselPageA Page that users can swipe from side to side to display pages of content, like a gallery.
CellProvides base class and capabilities for all Forms cells. Cells are elements meant to be added to ListView or TableView.
CollectionSynchronizationCallbackDelegate for callback in BindingBase.EnableCollectionSynchronization.
ColorClass that represents a color and exposes it as RGBA and HSL values.
ColorTypeConverterA TypeConverter that converts from strings to a Color.
ColumnDefinitionAn IDefinition that defines properties for a column in a Grid.
ColumnDefinitionCollectionA DefinitionCollection`1 for ColumnDefinitions.
CommandDefines an ICommand implementation that wraps a Action.
Command<T>Defines an ICommand implementation wrapping a generic Action<T>.
ConditionBase class for conditions.
Configuration<TPlatform,TElement>Utility class for retrieving platform-specific versions of elements.
ConstraintA layout constraint used by RelativeLayouts.
ConstraintExpressionDefines a constraint relationship.
ConstraintTypeEnumeration specifying whether a constraint is constant, relative to a view, or relative to its parent.
ConstraintTypeConverterA TypeConverter that converts from strings to a Constraint.
ContentPageA Page that displays a single view.
ContentPresenterLayout manager for templated views.
ContentPropertyAttributeIndicates the property of the type that is the (default) content property.
ContentViewAn element that contains a single child element.
ControlTemplateTemplate that specifies a group of styles and effects for controls.
DataTemplateA template for multiple bindings, commonly used by ListViews and MultiPages.
DataTemplateSelectorSelects DataTemplate objects by data type and container.
DataTriggerClass that represents a binding condition and a list of Setter objects that will be applied when the condition is met.
DateChangedEventArgsEvent arguments for DatePicker.DateSelected event.
DatePickerA View that allows date picking.
DefinitionCollection<T>A collection parameterized by an IDefinition. Base class for ColumnDefinitionCollection and RowDefinitionCollection.
DependencyAttributeAn attribute that indicates that the specified type provides a concrete implementation of a needed interface.
DependencyFetchTargetEnumeration specifying whether DependencyService.Get should return a reference to a global or new instance.
DependencyServiceStatic class that provides the DependencyService.Get<T> factory method for retrieving platform-specific implementations of the specified type T.
DeviceA utility class to interact with the current Device/Platform.
Device+StylesClass that exposes device-specific styles as static fields.
EasingFunctions that modify values non-linearly, generally used for animations.
EditorA control that can edit multiple lines of text.
EffectA collection of styles and properties that can be added to an element at run time.
ElementProvides the base class for all Forms hierarchal elements. This class contains all the methods and properties required to represent an element in the Forms hierarchy.
ElementEventArgsProvides data for events pertaining to a single Element.
ElementTemplateBase class for DataTemplate and ControlTemplate classes.
EntryA control that can edit a single line of text.
EntryCellA Cell with a label and a single line text entry field.
EventTriggerClass that represents a triggering event and a list of TriggerAction objects that will be invoked when the event is raised.
ExportEffectAttributeAttribute that identifies a Effect with a unique identifier that can be used with Effect.Resolve to locate an effect.
FileImageSourceAn ImageSource that reads an image from a file.
FileImageSourceConverterA TypeConverter that converts to Forms.FileImageSource.
FocusEventArgsEvent args for VisualElement's VisualElement.Focused and Unfocused events.
FontThe font used to display text.
FontAttributesEnumerates values that describe font styles.
FontSizeConverterConverts a string into a font size.
FontTypeConverterA TypeConverter that converts from strings to Font.
FormattedStringRepresents a text with attributes applied to some parts.
FrameAn element containing a single child, with some framing options.
GestureRecognizerThe base class for all gesture recognizers.
GestureStateEnumeration specifying the various states of a gesture.
GestureStatusEnumerates possible gesture states.
GridA layout that arranges views in rows and columns.
Grid+IGridList<T>List interface with overloads for adding elements to a grid.
GridLengthUsed to define the size (width/height) of Grid ColumnDefinition and RowDefinition.
GridLengthTypeConverterA TypeConverter that converts from strings to GridLengths.
GridUnitTypeEnumerates values that control how the GridLength.Value property is interpreted for row and column definitions.
HandlerAttributeAn abstract attribute whose subclasses specify the platform-specific renderers for Xamarin.Forms abstract controls.
HtmlWebViewSourceA WebViewSource bound to an HTML-formatted string.
IAnimatableDefines an interface for elements that can be animated.
IAppIndexingProviderThis interface is for internal use by platform renderers.
IApplicationControllerFor internal use by platform renderers.
IAppLinkEntryInterface that represents a deep application link in an app link search index.
IAppLinksInterface that defines the methods that are required for registering and deregistering links to content in apps.
IButtonControllerFor internal use by platform renderers.
ICellControllerFor internal use by platform renderers.
IConfigElement<T>This interface is for internal use by platform renderers.
IConfigPlatformBase interface for marker classes that identify target platforms for platform specific effects.
IDefinitionInterface defining the type of RowDefinition and ColumnDefinition.
IEffectControlProviderWhen implemented in a renderer, registers a platform-specific effect on an element.
IElementConfiguration<TElement>Interface for returning the platform-specific instance of a Xamarin.Forms type.
IElementControllerFor internal use by platform renderers.
IEntryCellControllerFor internal use by platform renderers.
IEntryControllerFor internal use by platform renderers.
IExtendedTypeConverterBase class for type converters.
IGestureRecognizerThe base interface all gesture recognizers must implement.
IImageControllerFor internal use by platform renderers.
IItemsView<T>This interface is for internal use by platform renderers.
IItemViewControllerFor internal use by platform renderers.
ILayoutInterface indicating layout behavior and exposing the ILayout.LayoutChanged event.
ILayoutControllerFor internal use by platform renderers.
IListProxyThis interface is for internal use by platform renderers.
IListViewControllerFor internal use by platform renderers.
Image View that holds an image.
ImageCellA TextCell that has an image.
ImageSourceAbstract class whose implementors load images from files or the Web.
ImageSourceConverterClass that takes a string representation of an image file location and returns a ImageSource from the specified resource.
IMasterDetailPageControllerFor internal use by platform renderers.
IMenuItemControllerFor internal use by platform renderers.
INativeElementViewInterface that contains a read-only property that returns the platform-specific native view for a Xamarin.Forms element.
INavigationInterface abstracting platform-specific navigation.
INavigationPageControllerFor internal use by platform renderers.
InputViewThe base class of a view which can take keyboard input.
IOpenGlViewControllerFor internal use by platform renderers.
IOpenGlViewControllerFor internal use by platform renderers.
IPageContainer<T>Interface defining a container for Pages and exposing a IPageContainer`1.CurrentPage property.
IPageControllerFor internal use by platform renderers.
IPlatformInterface defining the abstraction of a native platform.
IPlatformElementConfiguration<TPlatform,TElement>Marker interface for returning platform-specific configuration elements.
IPlatformEngineInterface defining a native platform rendering engine.
IRegisterableInternally-used flagging interface indicating types that can be registered with Registrar.
IScrollViewControllerFor internal use by platform renderers.
ISearchBarControllerFor internal use by platform renderers.
IStreamImageSourceThis interface is for internal use by platform renderers.
ITableModelThis interface is for internal use by platform renderers.
ITableViewControllerFor internal use by platform renderers.
ITemplatedItemsList<TItem>This interface is for internal use by platform renderers.
ITemplatedItemsListScrollToRequestedEventArgsThis interface is for internal use by platform renderers.
ITemplatedItemsView<TItem>This interface is for internal use by platform renderers.
ItemsView<TVisual>A base class for a view that contains a templated list of items.
ItemTappedEventArgsEvent arguments for the ListView.ItemTapped event.
ItemVisibilityEventArgsEvent args when an items visiblity has been changed in a ListView.
IValueConverterInterface defining methods for two-way value conversion between types.
IViewContainer<T>The type of element that can be added to the container.
IViewControllerThis interface is for internal use by platform renderers.
IVisualElementControllerFor internal use by platform renderers.
IWebViewDelegateThis interface is for internal use by platform renderers.
KeyboardDefault keyboard and base class for specialized keyboards, such as those for telephone numbers, email, and URLs.
KeyboardFlagsFlagging enumeration for Keyboard options such as Capitalization, Spellcheck, and Suggestions.
KeyboardTypeConverterA TypeConverter that converts a string into a Keyboard.
LabelA View that displays text.
LayoutProvides the base class for all Layout elements. Use Layout elements to position and size child elements in Forms applications.
Layout<T>A base implementation of a layout with undefined behavior and multiple children.
LayoutAlignmentValues that represent LayoutAlignment.
LayoutOptionsA struct whose static members define various alignment and expansion options.
LayoutOptionsConverterClass that takes a string representation of a LayoutOptions and returns a corresponding LayoutOptions.
LineBreakModeEnumeration specifying various options for line breaking.
ListStringTypeConverterType converter for converting properly formatted string lists to lists.
ListViewAn ItemsView that displays a collection of data as a vertical list.
ListViewCachingStrategyEnumerates caching strategies for a ListView.
MasterBehaviorEnumerates values that control how detail content is displayed in a master-detail page.
MasterDetailPageA Page that manages two panes of information: A master page that presents data at a high level, and a detail page that displays low-level details about information in the master.
MeasureFlagsEnumerates values that tell whether margins are included when laying out windows.
MenuItemClass that presents a menu item and associates it with a command.
MessagingCenterAssociates a callback on subscribers with a specific message name.
ModalEventArgsBase class for ModalPushedEventArgs, ModalPushingEventArgs, ModalPoppedEventArgs, and ModalPoppingEventArgs.
ModalPoppedEventArgsArguments for the event that is raised when a modal window is popped from the navigation stack.
ModalPoppingEventArgsArguments for the event that is raised when a modal window is popping from the navigation stack.
ModalPushedEventArgsArguments for the event that is raised when a modal window is pushed onto the navigation stack.
ModalPushingEventArgsArguments for the event that is raised when a modal window is being pushed onto the navigation stack.
MultiPage<T>A bindable, templatable base class for pages which contain multiple sub-pages.
MultiTriggerClass that represents a list of property and binding conditions, and a list of setters that are applied when all of the conditions in the list are met.
NamedSizeRepresents pre-defined font sizes.
NameScopeExtensionsExtension methods for Element and INameScope that add strongly-typed FindByName methods.
NavigationEventArgsEventArgs for the NavigationPage's navigation events.
NavigationMenuFor internal use only.
NavigationPageA Page that manages the navigation and user-experience of a stack of other pages.
OnClass that is used within OnPlatform tags in XAML when specifying values on platforms.
OnIdiom<T>Provides idiom-specific implementation of T for the current target idiom.
OnPlatform<T>Provides the platform-specific implementation of T for the current Device.OS.
OpenGLViewA View that displays OpenGL content.
PageA VisualElement that occupies the entire screen.
PanGestureRecognizerA gesture recognizer for panning content that is larger than its parent view.
PanUpdatedEventArgsEvent that is raised when a pan gesture updates.
PickerA View control for picking an element in a list.
PinchGestureRecognizerRecognizer for pinch gestures.
PinchGestureUpdatedEventArgsEvent arguments for the PinchGestureRecognizer.PinchUpdated event.
PlatformEffect<TContainer,TControl>Base class for platform-specific effect classes.
PointStruct defining a 2-D point as a pair of doubles.
PointTypeConverterA TypeConverter that converts from a string to a Point.
PoppedToRootEventArgsEventArgs for the NavigationPage's PoppedToRoot navigation event.
ProgressBarA View control that displays progress.
PropertyChangingEventArgsEvent arguments for the PropertyChangingEventHandler delegate.
PropertyChangingEventHandlerDelegate for the BindableObject.PropertyChanging event.
PropertyConditionClass that represents a value comparison with a property.
RectangleStruct defining a rectangle, using doubles.
RectangleTypeConverterA TypeConverter that converts a string to a Rectangle.
RelativeLayoutA Layout`1 that uses Constraints to layout its children.
RelativeLayout+IRelativeList<T>An IList`1 of Views used by a RelativeLayout.
RenderWithAttributeAssociate view with renderer.
ResolutionGroupNameAttributeAttribute that identifies a group name, typically a company name or reversed company URL, that provides a scope for effect names.
ResourceDictionaryAn IDictionary that maps identifier strings to arbitrary resource objects.
RoutingEffectPlatform-independent effect that wraps an inner effect, which is usually platform-specific.
RowDefinitionAn IDefinition that defines properties for a row in a Grid.
RowDefinitionCollectionA DefinitionCollection`1 for RowDefinitions.
ScrolledEventArgsArguments for the event that is raised when a window is scrolled.
ScrollOrientationEnumeration specifying vertical or horizontal scrolling directions.
ScrollToModeEnumerates values that describe how a scroll request is made.
ScrollToPositionEnumerates values that describe a scroll request.
ScrollToRequestedEventArgsArguments for the event that is raised when a scroll is requested.
ScrollViewAn element capable of scrolling if its Content requires.
SearchBarA View control that provides a search box.
SelectedItemChangedEventArgsEvent arguments for the ListView.ItemSelected event.
SelectedPositionChangedEventArgsEvent arguments for positional scrolling events.
SeparatorVisibilityEnumerates values that control the visibility of list item separators.
SetterRepresents an assignment of a property to a value, typically in a style or in response to a trigger.
SettersExtensionsDefines extensions methods for IList<Setter>
SizeStruct defining height and width as a pair of doubles.
SizeRequestStruct that definse minimum and maximum Sizes.
SliderA View control that inputs a linear value.
SpanRepresents a part of a FormattedString.
StackLayoutA Layout`1 that positions child elements in a single line which can be oriented vertically or horizontally.
StackOrientationThe orientations the a StackLayout can have.
StepperA View control that inputs a discrete value, constrained to a range.
StreamImageSource ImageSource that loads an image from a Stream.
StyleClass that contains triggers, setters, and behaviors that completely or partially define the appearance and behavior of a class of visual elements.
SwitchA View control that provides a toggled value.
SwitchCellA Cell with a label and an on/off switch.
TabbedPage MultiPage`1 that displays an array of tabs across the top of the screen, each of which loads content onto the screen.
TableIntentTableIntent provides hints to the renderer about how a table will be used.
TableRootA TableSection that contains either a table section or the entire table.
TableSectionA logical and visible section of a TableView.
TableSectionBaseAbstract base class defining a table section.
TableSectionBase<T> Table section that contains instances of type T that are rendered by Xamarin.Forms.
TableViewA View that holds rows of Cell elements.
TapGestureRecognizerProvides tap gesture recognition and events.
TappedEventArgsArguments for the TappedEvent event.
TargetIdiomIndicates the type of device Forms is working on.
TargetPlatformIndicates the kind of OS Forms is currently working on.
TemplateBindingBinds a template property to the parent of the view that owns a ControlTemplate.
TemplatedPageA page that displays full-screen content with a control template, and the base class for ContentPage.
TemplatedViewA view that displays content with a control template, and the base class for ContentView.
TemplateExtensionsExtension class for DataTemplate, providing a string-based shortcut method for defining a Binding.
TextAlignmentEnumerates values that control text alignment.
TextCell A Cell with primary TextCell.Text and TextCell.Detail text.
TextChangedEventArgsEvent arguments for TextChanged events. Provides old and new text values.
ThicknessStruct defining thickness around the edges of a Rectangle using doubles.
ThicknessTypeConverterA TypeConverter that converts from a string to a Thickness.
TimePickerA View control that provides time picking.
ToggledEventArgsEvent arguments for Switch.Toggled and SwitchCell.OnChanged events.
ToolbarItemAn item in a toolbar or displayed on a Page.
ToolbarItemOrderEnumeration specifying whether the ToolbarItem appears on the primary toolbar surface or secondary.
TriggerClass that represents a property condition and an action that is performed when the condition is met.
TriggerActionA base class for user-defined actions that are performed when a trigger condition is met.
TriggerAction<T>A generic base class for user-defined actions that are performed when a trigger condition is met.
TriggerBaseBase class for classes that contain a condition and a list of actions to perform when the condition is met.
TypeConverterAbstract base class whose subclasses can convert values between different types.
TypeConverterAttributeAttribute that specifies the type of TypeConverter used by its target.
TypeTypeConverterClass that takes a string representation of a Type and returns a corresponding Type.
UnsolvableConstraintsExceptionException indicating that the Constraints specified cannot be simultaneously satisfied.
UriImageSourceAn ImageSource that loads an image from a URI, caching the result.
UriTypeConverterA TypeConverter that converts from a string or Uri to a Uri.
UrlWebViewSourceA WebViewSource bound to a URL.
ValueChangedEventArgsEvent arguments for ValueChanged events. Provides both old and new values.
Vec2Struct defining X and Y double values.
ViewA visual element that is used to place layouts and controls on the screen.
ViewCellA Cell containing a developer-defined View.
ViewExtensionsExtension methods for Views, providing animatable scaling, rotation, and layout functions.
ViewStateDeprecated. Do not use.
VisualElementA Element that occupies an area on the screen, has a visual appearance, and can obtain touch input.
WebNavigatedEventArgsClass that contains arguments for the event that is raised after web navigation completes.
WebNavigatingEventArgsClass that contains arguments for the event that is raised after web navigation begins.
WebNavigationEventContains values that indicate why a navigation event was raised.
WebNavigationEventArgsTClass that contains arguments for the event that is when web navigation begins.
WebNavigationResultEnumerates values that indicate the outcome of a web navigation.
WebViewA View that presents HTML content.
WebViewSourceAbstract class whose subclasses provide the data for a WebView.
WebViewSourceTypeConverterA TypeConverter that converts a string to a UrlWebViewSource.