共用方式為


TemplateBinding 類別

定義

警告

Use Binding.Source=RelativeBindingSource.TemplatedParent

將範本屬性繫結至 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
繼承
TemplateBinding
屬性

備註

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

應用程式開發人員可以透過 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)
已過時。.

建立空白範本繫結。

屬性

Converter
已過時。.

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

ConverterParameter
已過時。.

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

FallbackValue
已過時。.

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

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

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

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

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

StringFormat
已過時。.

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

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

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

(繼承來源 BindingBase)

方法

ThrowIfApplied()
已過時。.

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

(繼承來源 BindingBase)

適用於