ispiro ispiro - 5 months ago 33
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">


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);