BindableAttribute 類別

定義

指定 C++ 中定義的型別可用於系結。

public ref class BindableAttribute sealed : Attribute
/// [Windows.Foundation.Metadata.AttributeUsage(System.AttributeTargets.RuntimeClass)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class BindableAttribute final : Attribute
/// [Windows.Foundation.Metadata.AttributeUsage(System.AttributeTargets.RuntimeClass)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.AttributeName("bindable")]
class BindableAttribute final : Attribute
[Windows.Foundation.Metadata.AttributeUsage(System.AttributeTargets.RuntimeClass)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class BindableAttribute : Attribute
[Windows.Foundation.Metadata.AttributeUsage(System.AttributeTargets.RuntimeClass)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.AttributeName("bindable")]
public sealed class BindableAttribute : Attribute
Public NotInheritable Class BindableAttribute
Inherits Attribute
繼承
BindableAttribute
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列程式碼範例顯示此屬性的一般使用模式。 如需完整的程式代碼清單,請參閱 XAML 資料系結範例

如果您使用C++/WinRT,則只有在您使用{Binding}標記延伸時,才需要新增BindableAttribute。 如果您使用 {x:Bind} 標記延伸,則不需要 BindableAttribute (以取得詳細資訊,請參閱 XAML 控制項;系結至 C++/WinRT 屬性) 。

// MyColors.idl
namespace MyColorsApp
{
    [bindable]
    [default_interface]
    runtimeclass MyColors : Windows.UI.Xaml.Data.INotifyPropertyChanged
    {
        MyColors();
        Windows.UI.Xaml.Media.SolidColorBrush Brush1;
    }
}
[Windows::UI::Xaml::Data::Bindable]
public ref class Employee sealed : Windows::UI::Xaml::Data::INotifyPropertyChanged
{
    // ...
}

備註

將此屬性套用至以 C++ 為基礎的資料類別,以啟用其作為系結來源的使用。 Common Language Runtime (CLR) 類型,包括 C# 和 Microsoft Visual Basic 中定義的所有類型,預設都是可系結的。 您也可以實作 ICustomPropertyProvider,讓類型成為可系結的。 如需詳細資訊,請參閱深入了解資料繫結

建構函式

BindableAttribute()

初始化 BindableAttribute 類別的新實例。

適用於

另請參閱