Xamarin.Forms Namespace

Cross-platform, natively-backed UI toolkit.

Remarks

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. The user interfaces use the native controls of the target platform.

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 Pad 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
{
    public static Page GetMainPage()
    {
        return new ContentPage
        {
            Content = new Label
            {
                Text = "Hello, Forms!",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            },
        };
    }
}          
          

The iOS platform code would look like this:

C# Example

[Register("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
    UIWindow window;

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        Forms.Init();

        window = new UIWindow(UIScreen.MainScreen.Bounds);
        window.RootViewController =  App.GetMainPage().CreateViewController();
        window.MakeKeyAndVisible();

        return true;
    }
}
          

The Android platform code would look like this:

C# Example

namespace HelloXamarinFormsWorld.Android
{
    [Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true)]
    public class MainActivity : AndroidActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);

            SetPage(App.GetMainPage());
        }
    }
}
          

And the Windows Phone code would look like this:

C# Example

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        Forms.Init();
        Content = HelloXamarinFormsWorld.App.GetMainPage().ConvertPageToUIElement(this);
    }
}
          

The resulting app looks like this on the various device:

Elements in Xamarin.Forms

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

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 Xamarin.Forms.BindableObject and Xamarin.Forms.BindableProperty classes. Objects that inherit from Xamarin.Forms.BindableObject can be bound to members of type Xamarin.Forms.BindableProperty on other objects.

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

Classes

TypeReason
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 Xamarin.Forms.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 Xamarin.Forms.Animation.
ApplicationClass that represents a cross-platform mobile application.
AspectDefines how an image is displayed.
BackButtonPressedEventArgsContains 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. Xamarin.Forms.BindableProperty.
BindableObjectExtensionsContains convenience extension methods for Xamarin.Forms.BindableObject.
BindablePropertyA BindableProperty is a backing store for properties allowing bindings on Xamarin.Forms.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.
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 Xamarin.Forms.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 Xamarin.Forms.Binding
BoundsConstraintA bounds layout constraint used by Xamarin.Forms.RelativeLayouts.
BoundsTypeConverterA Xamarin.Forms.TypeConverter that converts strings into Xamarin.Forms.Rectangles for use with Xamarin.Forms.AbsoluteLayouts.
BoxViewA Xamarin.Forms.View used to draw a solid colored rectangle.
ButtonA button Xamarin.Forms.View that reacts to touch events.
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 Xamarin.Forms.ListView or Xamarin.Forms.TableView.
CollectionSynchronizationCallbackDelegate for callback in Xamarin.Forms.BindingBase.EnableCollectionSynchronization.
ColorClass that represents a color and exposes it as RGBA and HSL values.
ColorTypeConverterA Xamarin.Forms.TypeConverter that converts from strings to a Xamarin.Forms.Color.
ColumnDefinitionAn Xamarin.Forms.IDefinition that defines properties for a column in a Xamarin.Forms.Grid.
ColumnDefinitionCollectionA Xamarin.Forms.DefinitionCollection`1 for Xamarin.Forms.ColumnDefinitions.
CommandDefines an System.Windows.Input.ICommand implementation wrapping an stem.Action.
Command<T>Defines an System.Windows.Input.ICommand implementation wrapping a generic Action<T>.
ConditionBase class for conditions.
ConstraintA layout constraint used by Xamarin.Forms.RelativeLayouts.
ConstraintExpressionDefines a constraint relationship.
ConstraintTypeEnumeration specifying whether a constraint is constant, relative to a view, or relative to its parent.
ConstraintTypeConverterA Xamarin.Forms.TypeConverter that converts from strings to a Xamarin.Forms.Constraint.
ContentPageA Xamarin.Forms.Page that displays a single view.
ContentPropertyAttributeIndicates the property of the type that is the (default) content property.
ContentViewAn element that contains a single child element.
DataTemplateA template for multiple bindings, commonly used by Xamarin.Forms.ListViews, Xamarin.Forms.MultiPages, and Xamarin.Forms.TableViews.
DataTriggerClass that represents a binding condition and a list of Xamarin.Forms.Setter objects that will be applied when the condition is met.
DateChangedEventArgsEvent arguments for Xamarin.Forms.DatePicker.DateSelected event.
DatePickerA Xamarin.Forms.View that allows date picking.
DefinitionCollection<T>A collection parameterized by an Xamarin.Forms.IDefinition. Base class for Xamarin.Forms.ColumnDefinitionCollection and Xamarin.Forms.RowDefinitionCollection.
DependencyAttributeAn attribute that indicates that the specified type provides a concrete implementation of a needed interface.
DependencyFetchTargetEnumeration specifying whether Xamarin.Forms.DependencyService.Get should return a reference to a global or new instance.
DependencyServiceStatic class that provides the Xamarin.Forms.DependencyService.Get`1 factory method for retrieving platform-specific implementations of the specified type T.
DeviceAn utility class to interract 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.
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 Xamarin.Forms.Element.
EntryA control that can edit a single line of text.
EntryCellA Xamarin.Forms.Cell with a label and a single line text entry field.
EventTriggerClass that represents a triggering event and a list of Xamarin.Forms.TriggerAction objects that will be invoked when the event is raised.
FileImageSourceAn Xamarin.Forms.ImageSource that reads an image from a file.
FocusEventArgsEvent args for Xamarin.Forms.VisualElement's Xamarin.Forms.VisualElement.Focused and Xamarin.Forms.VisualElement.Unfocused events.
FontThe font used to display text.
FontAttributesEnumerates values that describe font styles.
FontSizeConverterConverts a string into a font size.
FontTypeConverterA Xamarin.Forms.TypeConverter that converts from strings to Xamarin.Forms.Core.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.
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 Xamarin.Forms.TypeConverter that converts from strings to Xamarin.Forms.GridLengths.
GridUnitTypeEnumerates values that control how the Xamarin.Forms.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.
IDefinitionInterface defining the type of Xamarin.Forms.RowDefinition and Xamarin.Forms.ColumnDefinition.
IElementControllerWhen implemented in a derived class, sets the value on bound properties so that their bindings are preserved.
IGestureRecognizerThe base interface all gesture recognizers must implement.
ILayoutInterface indicating layout behavior and exposing the Xamarin.Forms.ILayout.LayoutChanged event.
Image Xamarin.Forms.View that holds an image.
ImageCellA Xamarin.Forms.TextCell that has an image.
ImageSourceAbstract class whose implementors load images from files or the Web.
INavigationInterface abstracting platform-specific navigation.
InputViewThe base class of a view which can take keyboard input.
IPageContainer<T>Interface defining a container for Xamarin.Forms.Pages and exposing a Xamarin.Forms.IPageContainer`1.CurrentPage property.
IPlatformInterface defining the abstraction of a native platform.
IPlatformEngineInterface defining a native platform rendering engine.
IRegisterableInternally-used flagging interface indicating types that can be registered with Xamarin.Forms.Registrar.
ItemsView<TVisual>A base class for a view that contains a templated list of items.
ItemTappedEventArgsEvent arguments for the Xamarin.Forms.ListView.ItemTapped event.
ItemVisibilityEventArgsEvent args when an items visiblity has been changed in a Xamarin.Forms.ListView.
IValueConverterInterface defining methods for two-way value conversion between types.
IViewContainer<T>The type of element that can be added to the container.
IViewControllerContains methods that set values from renderers on bound properties without breaking the binding.
IVisualElementControllerMethod that is called when the native size of a visual element changes.
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 Xamarin.Forms.TypeConverter that converts a string into a Xamarin.Forms.Keyboard.
LabelA Xamarin.Forms.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.
LineBreakModeEnumeration specifying various options for line breaking.
ListViewAn Xamarin.Forms.ItemsView that displays a collection of data as a vertical list.
MasterBehaviorEnumerates values that control how detail content is displayed in a master-detail page.
MasterDetailPageA Xamarin.Forms.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.
MenuItemClass that presents a menu item and associates it with a command.
MessagingCenterAssociates a callback on subscribers with a specific message name.
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 Xamarin.Forms.Element and Xamarin.Forms.INameScope that add strongly-typed FindByName methods.
NavigationEventArgsEventArgs for the NavigationPage's navigation events.
NavigationPageA Xamarin.Forms.Page that manages the navigation and user-experience of a stack of other pages.
OnIdiom<T>Provides idiom-specific implementation of T for the current TargetIdiom.
OnPlatform<T>Provides the platform-specific implementation of T for the current Xamarin.Forms.Device.OS.
OpenGLViewA Xamarin.Forms.View that displays OpenGL content.
PageA Xamarin.Forms.VisualElement that occupies the entire screen.
PickerA Xamarin.Forms.View control for picking an element in a list.
PointStruct defining a 2-D point as a pair of doubles.
PointTypeConverterA Xamarin.Forms.TypeConverter that converts from a string to a Xamarin.Forms.Point.
ProgressBarA Xamarin.Forms.View control that displays progress.
PropertyChangingEventArgsEvent arguments for the Xamarin.Forms.PropertyChangingEventHandler delegate.
PropertyChangingEventHandlerDelegate for the Xamarin.Forms.BindableObject.PropertyChanging event.
PropertyConditionClass that represents a value comparison with a property.
RectangleStruct defining a rectangle, using doubles.
RectangleTypeConverterA Xamarin.Forms.TypeConverter that converts a string to a Xamarin.Forms.Rectangle.
RelativeLayoutA Xamarin.Forms.Layout`1 that uses Xamarin.Forms.Constraints to layout its children.
RelativeLayout+IRelativeList<T>An IList`1 of Xamarin.Forms.Views used by a Xamarin.Forms.RelativeLayout.
RenderWithAttributeAssociate view with renderer.
ResourceDictionaryAn IDictionary that maps identifier strings to arbitrary resource objects.
RowDefinitionAn Xamarin.Forms.IDefinition that defines properties for a row in a Xamarin.Forms.Grid.
RowDefinitionCollectionA Xamarin.Forms.DefinitionCollection`1 for Xamarin.Forms.RowDefinitions.
ScrollOrientationEnumeration specifying vertical or horizontal scrolling directions.
ScrollToPositionEnumerates values that describe a scroll request.
ScrollViewAn element capable of scrolling if its Content requires.
SearchBarA Xamarin.Forms.View control that provides a search box.
SelectedItemChangedEventArgsEvent arguments for the Xamarin.Forms.ListView.ItemSelected event.
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 defining minimum and maximum Xamarin.Forms.Sizes.
SliderA Xamarin.Forms.View control that inputs a linear value.
SpanRepresents a part of a FormattedString.
StackLayoutA Xamarin.Forms.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 Xamarin.Forms.View control that inputs a discrete value, constrained to a range.
StreamImageSource Xamarin.Forms.ImageSource that loads an image from a System.IO.Stream.
StyleClass that contains triggers, setters, and behaviors that completely or partially define the appearance and behavior of a class of visual elements.
SwitchA Xamarin.Forms.View control that provides a toggled value.
SwitchCellA Xamarin.Forms.Cell with a label and an on/off switch.
TabbedPage Xamarin.Forms.MultipPage`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 Xamarin.Forms.TableSection that contains either a table section or the entire table.
TableSectionA logical and visible section of a Xamarin.Forms.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 Xamarin.Forms.View that holds rows of Xamarin.Forms.Cell elements.
TapGestureRecognizerProvides tap gesture recognition and events.
TappedEventArgsArguments for the Xamarin.Forms.TappedEvent event.
TargetIdiomIndicates the type of device Forms is working on.
TargetPlatformIndicates the kind of OS Forms is currently working on.
TemplateExtensionsExtension class for DataTemplate, providing a string-based shortcut method for defining a Binding.
TextAlignmentRepresents vertical and horizontal text alignement.
TextCell A Xamarin.Forms.Cell with primary Xamarin.Forms.TextCell.Text and Xamarin.Forms.TextCell.Detail text.
TextChangedEventArgsEvent arguments for TextChanged events. Provides old and new text values.
ThicknessStruct defining thickness around the edges of a Xamarin.Forms.Rectangle using doubles.
ThicknessTypeConverterA Xamarin.Forms.TypeConverter that converts from a string to a Xamarin.Forms.Thickness.
TimePickerA Xamarin.Forms.View control that provides time picking.
ToggledEventArgsEvent arguments for Xamarin.Forms.Switch.Toggled and Xamarin.Forms.SwitchCell.OnChanged events.
ToolbarItemAn item in a toolbar or displayed on a Xamarin.Forms.Page.
ToolbarItemOrderEnumeration specifying whether the Xamarin.Forms.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 Xamarin.Forms.TypeConverter used by its target.
UnsolvableConstraintsExceptionException indicating that the Xamarin.Forms.Constraints specified cannot be simultaneously satisfied.
UriImageSourceAn ImageSource that loads an image from a URI, caching the result.
UriTypeConverterA Xamarin.Forms.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 Xamarin.Forms.Cell containing a developer-defined Xamarin.Forms.View.
ViewExtensionsExtension methods for Xamarin.Forms.Views, providing animatable scaling, rotation, and layout functions.
ViewStateDeprecated. Do not use.
VisualElementA Xamarin.Forms.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 Xamarin.Forms.View that presents HTML content.
WebViewSourceAbstract class whose subclasses provide the data for a Xamarin.Forms.WebView.
WebViewSourceTypeConverterA Xamarin.Forms.TypeConverter that converts a string to a Xamarin.Forms.UrlWebViewSource.