In WPF, the FrameworkElement class includes a Tag property that allows storing some arbitrary data with an element. You'd normally use the Tag property to store some custom data on an element that inherits from FrameworkElement.
Or you might use Tag as a way for an applied style to get a value from an arbitrary FrameworkElement parent into a specific applied template using {TemplateBinding} markup extension, without requiring XAML namespace mapping of a specific instance property in app XAML.
clr-namespace: The CLR namespace declared within the assembly that contains the public types to expose as elements. assembly= The assembly that contains some or all of the referenced CLR namespace. This value is typically just the name of the assembly, not the path, and does not include the extension (such as .
Extensible Application Markup Language (XAML /ˈzæməl/ ( listen)) is a declarative XML-based language that Microsoft developed for initializing structured values and objects. It is available under Microsoft's Open Specification Promise. Extensible Application Markup Language (XAML) Filename extension. .xaml.
MSDN says "Gets or sets an arbitrary object value that can be used to store custom information about this element." which means I can store anything I want in this property.
But if you bind to this property (with property of type String having a value say "XYZ") and use it in Trigger conditions it doesn't work!
<Trigger Property="Tag" Value="XYZ">
<Setter Property="Background" Value="Red" />
</Trigger>
It does not set the background red. You can try and assume myElement to be a TextBlock! Why is it like this?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With