ispiro ispiro - 1 year ago 116
C# Question

How to get the value of an attached property in code?

I have a button with a

in it.
How do I access it in code?


<Button Name="testButton">

Answer Source

To get the value of an attached property, use the provided static method:

var tooltip = ToolTipService.GetToolTip(testButton);

If there is no such static method (not likely, all classes should have static helper methods to get/set attached properties they expose), then use:

var tooltip = testButton.GetValue(ToolTipService.ToolTipProperty);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download