#145 – Dependency Property Value Sources: #11 – Default Value
December 4, 2010 2 Comments
The eleventh source in the list of sources for the base value of a dependency property is the default value. A dependency property may define a default value that will become the property’s value if no mechanism with higher precedence assigns a value.
As an example, notice that the value of the Opacity property for most controls inheriting from UIElement (e.g. Button or Label) has a value of 1.0 if you don’t set it to anything else. This is the default value for the UIElement.Opacity property, specified in its metadata.
I like the watch window. Nice touch. I didn’t know that dependency properties have a DefaultMetadata property 🙂
Pingback: #133 – Where a Dependency Property Gets Its Value « 2,000 Things You Should Know About WPF