TemplateBinding TemplateBinding Class


Binds a template property to the parent of the view that owns a ControlTemplate.

public class TemplateBinding : Xamarin.Forms.BindingBase
type TemplateBinding = class
    inherit BindingBase


Control templates provide reusable styling and functionality for common UI elements in an application. They do this by providing a common set of properties that bind to the parents of the View that owns the View to which the control template is bound.

Application developers can assign these properties through XAML, as in the following example:

<ControlTemplate x:Key="LoginTemplate">
  <StackLayout VerticalOptions="CenterAndExpand" Spacing="20" Padding="20">
    <Entry Text="{TemplateBinding Username}" Placeholder="Username" />
    <Entry Text="{TemplateBinding Password}" Placeholder="Password" />
    <Button Command="{TemplateBinding Command}" Text="Click Here To Log In" />

Additionally, application developers can use the Xamarin.Forms.TemplateExtensions.SetBinding static method to set template bindings in code.


TemplateBinding() TemplateBinding()

Creates an empty template binding.

TemplateBinding(String, BindingMode, IValueConverter, Object, String) TemplateBinding(String, BindingMode, IValueConverter, Object, String)

Creates a new TemplateBinding with the specified values. Must be non-empty and non-null.


Converter Converter

Gets or sets the type converter to use to convert strings into instances of the bound property type.

ConverterParameter ConverterParameter

Gets or sets a format string to use for displaying property values.

Mode Mode

Gets or sets the mode for this binding.

(Inherited from BindingBase)
Path Path

Gets or sets a string that identifies the property to which to bind.

StringFormat StringFormat

Gets or sets the string format for this binding.

(Inherited from BindingBase)


ThrowIfApplied() ThrowIfApplied()

Throws an InvalidOperationException if the binding has been applied.

(Inherited from BindingBase)

Extension Methods

LoadFromXaml<TXaml>(TXaml, String) LoadFromXaml<TXaml>(TXaml, String)

Returns an initialized view by loading the specified xaml.

LoadFromXaml<TXaml>(TXaml, Type) LoadFromXaml<TXaml>(TXaml, Type)

Returns a TXaml with the properties that are defined in the application manifest for callingType.

Applies to