views:

38

answers:

3

I have seen that in Blend you can see which properties have been changed and use the reset option to get back to default values.

Is there any other way of finding what the default values of a control are?

JD

+1  A: 

Properties in XAML are set to their defaults when they aren't explicitly defined. So Reset in Blend actually just deletes the property from the XAML.

For example, if your control had a Color property:

<MyControl Width="100" Color="Blue"/>

Resetting the color would result in the following:

<MyControl Width="100"/>

This way, Blend doesn't require any knowledge of what a default value is.

For examining what the default values are, this is a little more difficult. The only methods I can think of is to either examine the control using the debugger during runtime, or examining the properties in a control using a tool such as XAMLPad. Documentation on a control may reveal what it's default is as well.

Will Eddins
Thanks for the info. Not used XAMLPad before so i will have a look at it.
JD
+2  A: 

You can determine the default value of a property by examining the DefaultMetadata property of the static DependencyProperty on the specific class, example:

TextBlock.TextProperty.DefaultMetadata.DefaultValue
Aviad P.
Thanks for the reply. I should have said I was looking for a tool but saying that, I suppose I could parse the XAML and call the function above for each property.
JD
A: 

Snoop highlights explicitly set property values at runtime and can give you an idea of the source (e.g. Parent Template).

Kevin Mills