Aracılığıyla paylaş


TemplateBinding Class

Definition

Caution

Use Binding.Source=RelativeBindingSource.TemplatedParent

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

public ref class TemplateBinding sealed : Microsoft::Maui::Controls::BindingBase
[System.Obsolete("Use Binding.Source=RelativeBindingSource.TemplatedParent")]
public sealed class TemplateBinding : Microsoft.Maui.Controls.BindingBase
[<System.Obsolete("Use Binding.Source=RelativeBindingSource.TemplatedParent")>]
type TemplateBinding = class
    inherit BindingBase
Public NotInheritable Class TemplateBinding
Inherits BindingBase
Inheritance
TemplateBinding
Attributes

Remarks

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" />
</StackLayout>
</ControlTemplate>

Additionally, application developers can use the SetBinding(DataTemplate, BindableProperty, String) static method to set template bindings in code.

Constructors

TemplateBinding()

Creates an empty template binding.

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

Creates an empty template binding.

Properties

Converter

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

ConverterParameter

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

FallbackValue

Gets or sets the value to use instead of the default value for the property, if no specified value exists.

(Inherited from BindingBase)
Mode

Gets or sets the mode for this binding.

(Inherited from BindingBase)
Path

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

StringFormat

Gets or sets the string format for this binding.

(Inherited from BindingBase)
TargetNullValue

Gets or sets the value to supply for a bound property when the target of the binding is null.

(Inherited from BindingBase)

Methods

ThrowIfApplied() (Inherited from BindingBase)

Applies to