TemplateBinding 類別

定義

警告

Use Binding.Source=RelativeBindingSource.TemplatedParent

將範本屬性繫結至 ControlTemplate 所屬檢視的父系。

[System.Obsolete("Use Binding.Source=RelativeBindingSource.TemplatedParent")]
public sealed class TemplateBinding : Xamarin.Forms.BindingBase
type TemplateBinding = class
    inherit BindingBase
繼承
TemplateBinding
屬性

備註

控制項範本可為應用程式中的通用 UI 元素提供可重複使用的樣式和功能。 它們藉由提供一組通用屬性,系結至擁有控制項範本所系結之檢視的檢視父系。

應用程式開發人員可以透過 XAML 指派這些屬性,如下列範例所示:

<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>

此外,應用程式開發人員可以使用 SetBinding(DataTemplate, BindableProperty, String) 靜態方法來在程式碼中設定範本系結。

建構函式

TemplateBinding()
已過時。

建立空白範本繫結。

TemplateBinding(String, BindingMode, IValueConverter, Object, String)
已過時。

使用指定值建立新的 TemplateBinding。 不得為空白或 Null。

屬性

Converter
已過時。

取得或設定用來將字串轉換成繫結屬性類型執行個體的類型轉換器。

ConverterParameter
已過時。

取得或設定用來顯示屬性值的格式字串。

FallbackValue
已過時。

如果不存在任何指定值,即取得或設定要使用的值來取代屬性的預設值。

(繼承來源 BindingBase)
Mode
已過時。

取得或設定這個繫結的模式。

(繼承來源 BindingBase)
Path
已過時。

取得或設定可識別所要繫結屬性的字串。

StringFormat
已過時。

取得或設定這個繫結的字串格式。

(繼承來源 BindingBase)
TargetNullValue
已過時。

當繫結的目標為 null 時,取得或設定要為繫結屬性提供的值。

(繼承來源 BindingBase)

方法

ThrowIfApplied()
已過時。

如果已套用繫結,則擲回 InvalidOperationException

(繼承來源 BindingBase)

適用於