NameScopePropertyAttribute 類別

定義

指定提供 XAML 命名範圍值之相關聯類別的屬性。

public ref class NameScopePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class NameScopePropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
type NameScopePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class NameScopePropertyAttribute
Inherits Attribute
繼承
NameScopePropertyAttribute
屬性

備註

在典型的物件模型/應用模型組合中,使用 XAML 命名範圍的類別通常用作根元素,或支援頁面隱喻的類別。 這些類別通常實作 INameScope ,XAML 名稱範圍則由典型的 XAML 處理行為建立,該行為與框架的程式設計模型與應用模型相符。

NameScopePropertyAttribute 使用 ,XAML 名稱範圍的屬性值預期會是一個物件,實作 INameScope 並保存實際的 XAML 名稱範圍及其行為。

此屬性有兩種形式:僅屬性名稱,或類型與屬性。 後者形式僅適用於持有 XAML 名稱範圍的屬性是可附加成員的情況。 附加成員技術的優點是服務類別可以實作 XAML 命名範圍概念,支援多種不同物件類型。 這些物件類型不需要在類別繼承中明確關聯。

在先前版本的 .NET 框架中,此類別存在於 WPF 專用的組合語言 WindowsBase 中。 在 .NET Framework 4 中,是 NameScopePropertyAttribute System.Xaml 組合語言。 更多資訊請參閱 「從 WPF 遷移到 System.Xaml」的類型。

WPF 使用方式注意事項

在 WPF 中,此屬性僅套用於單一類型 DependencyObject。 此時,歸屬性為服務類別 NameScope 及其 NameScope.NameScope 附加屬性。

建構函式

名稱 Description
NameScopePropertyAttribute(String, Type)

初始化一個以指定名稱和型別的新類別實例 NameScopePropertyAttribute

NameScopePropertyAttribute(String)

初始化一個以指定名稱的新 NameScopePropertyAttribute 類別實例。

屬性

名稱 Description
Name

取得提供 XAML 名稱範圍的屬性名稱。

Type

取得提供 XAML 名稱範圍支援的附加屬性的擁有者類型。

TypeId

在衍生類別中實作時,取得這個 Attribute的唯一標識碼。

(繼承來源 Attribute)

方法

名稱 Description
Equals(Object)

傳回值,這個值表示這個實例是否等於指定的物件。

(繼承來源 Attribute)
GetHashCode()

傳回這個實例的哈希碼。

(繼承來源 Attribute)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,指出這個實例的值是否為衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

明確介面實作

名稱 Description
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取 物件的型別資訊,可用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱