FrameworkElement.Tag FrameworkElement.Tag FrameworkElement.Tag FrameworkElement.Tag Property

定義

取得或設定可以用來儲存關於此元素自訂資訊的任意物件值。Gets or sets an arbitrary object value that can be used to store custom information about this element.

public:
 property System::Object ^ Tag { System::Object ^ get(); void set(System::Object ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
public object Tag { get; set; }
member this.Tag : obj with get, set
Public Property Tag As Object

屬性值

所要的值。The intended value. 此屬性沒有預設值。This property has no default value.

備註

這個屬性相當於其他 Microsoft 程式撰寫模型,例如 Visual Basic 應用程式或 Windows Form 中的標記屬性。This property is analogous to Tag properties in other Microsoft programming models, such as Visual Basic for Applications or Windows Forms. Tag 要提供的預先存在的屬性位置,您可以在其中儲存有關任何一些基本的自訂資訊FrameworkElement而不需要您的子類別的項目。Tag is intended to provide a pre-existing property location where you can store some basic custom information about any FrameworkElement without requiring you to subclass an element.

因為這個屬性會採用一個物件,您必須使用屬性的項目使用方式,若要設定Tag到具有已知與內建的類型轉換器,例如字串的物件以外的任何項目中 XAML 屬性。Because this property takes an object, you need to use the property element usage in order to set the Tag property in XAML to anything other than an object with a known and built-in type converter, such as a string. 使用此方法的物件通常不是標準的 WPF 命名空間內,而且因此可能需要外部的命名空間的命名空間對應,就會用作 XAML 項目。Objects used in this manner are typically not within the standard WPF namespaces and therefore may require namespace mapping to the external namespace in order to be introduced as XAML elements. 如需詳細資訊,請參閱 < XAML 命名空間和命名空間對應 WPF XAMLXAML 和自訂類別,如 WPFFor details, see XAML Namespaces and Namespace Mapping for WPF XAML and XAML and Custom Classes for WPF.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field TagProperty
若要設定的中繼資料屬性 trueMetadata properties set to true None

適用於

另請參閱