Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Tag" ... Special functionality in WPF?

Tags:

People also ask

What is Tag property in WPF?

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.

What is Tag in XAML?

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.

What is CLR namespace WPF?

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 .

What is .XAML file?

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?