FrameworkContentElement.Tag 属性


获取或设置任意对象值,该值可用于存储关于此元素的自定义信息。Gets or sets an arbitrary object value that can be used to store custom information about this element.

 property System::Object ^ Tag { System::Object ^ get(); void set(System::Object ^ value); };
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 for Applications 或 Windows 窗体。This property is analogous to Tag properties in other Microsoft programming models, such as Visual Basic for Applications or Windows Forms. 它旨在提供一个预先存在的位置来存储有关任何元素的一些基本自定义信息,而不会强制应用程序开发人员使用子类。It is intended to provide a pre-existing place to store some basic custom information about any element without forcing application developers to subclass.


由于此属性采用对象,因此您需要使用属性元素用法,以便将 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 way 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.

依赖项属性信息Dependency Property Information

标识符字段Identifier field TagProperty
元数据属性设置为 trueMetadata properties set to true None