RuntimeNamePropertyAttribute 類別

定義

代表類型層級屬性,該屬性報告此類型中哪個屬性對應到 XAML x:Name 屬性Represents a type-level attribute that reports which property of the type maps to the XAML x:Name attribute.

public ref class RuntimeNamePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class RuntimeNamePropertyAttribute : Attribute
type RuntimeNamePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class RuntimeNamePropertyAttribute
Inherits Attribute
繼承
RuntimeNamePropertyAttribute
屬性

備註

在中RuntimeNamePropertyAttribute指定的屬性必須屬於型String別, 而且必須是讀取/寫入。The property that is specified in the RuntimeNamePropertyAttribute must be of type String and must be read/write.

架構可能會將其中一個架構基底元素的特定屬性, 屬性為 XAML 名稱對等專案。Frameworks might attribute a certain property of one its architectural base elements to be the XAML name equivalent. 這麼做的目的是要在 xaml 載入時間設定 xaml 名稱範圍中 XAML 名稱的概念, 以便在執行時間于架構的程式設計模型中使用。This is done so that the concept of a XAML name in a XAML namescope set at XAML load time is available to a framework's programming model at run time.

XAML 名稱值必須使用XamlName 文法A XAML name value must use the XamlName Grammar.

在舊版的 .NET Framework 中, 這個類別會存在於 WPF 特定的元件 WindowsBase 中。In previous versions of the .NET Framework, this class existed in the WPF-specific assembly WindowsBase. .NET Framework 4.NET Framework 4RuntimeNamePropertyAttribute , 位於 system.object 元件中。In .NET Framework 4.NET Framework 4, RuntimeNamePropertyAttribute is in the System.Xaml assembly. 如需詳細資訊,請參閱 Types Migrated from WPF to System.XamlFor more information, see Types Migrated from WPF to System.Xaml.

WPF 使用注意事項WPF Usage Notes

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)現有類別的範例, RuntimeNamePropertyAttribute其中FrameworkElement套用了。An example of an existing class in Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) where the RuntimeNamePropertyAttribute is applied is FrameworkElement. Name RuntimeNamePropertyAttribute FrameworkElement的屬性會使用進行屬性化, 這會導致任何衍生類別Name也使用做為其執行時間名稱屬性。 FrameworkElementThe Name property on FrameworkElement is attributed with RuntimeNamePropertyAttribute, which results in any FrameworkElement derived class also using Name as its run-time name property.

一般而言, 除非您要執行新的或FrameworkElement平行架構層級類別, 否則通常不需要在 WPF 中套用此屬性。In general, you do not typically need to apply this attribute in WPF unless you are implementing a new or FrameworkElement-parallel framework-level class. x:Name如果兩個專案都以屬性的形式存在, 則應該優先于 [執行時間名稱] 屬性, 而在此情況下, XAML 處理器執行通常會擲回。x:Name should take precedence over the run-time name property if both exist as attributes on an element, and a XAML processor implementation generally throws in this case.

建構函式

RuntimeNamePropertyAttribute(String)

初始化 RuntimeNamePropertyAttribute 類別的新執行個體。Initializes a new instance of the RuntimeNamePropertyAttribute class.

屬性

Name

取得由這個 RuntimeNamePropertyAttribute 指定之執行階段名稱屬性的名稱。Gets the name of the runtime name property that is specified by this RuntimeNamePropertyAttribute.

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

(繼承來源 Attribute)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

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

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

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

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

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

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)

適用於

另請參閱