#145 – Dependency Property Value Sources: #11 – Default Value

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.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #145 – Dependency Property Value Sources: #11 – Default Value

  1. Basarat Ali says:

    I like the watch window. Nice touch. I didn’t know that dependency properties have a DefaultMetadata property 🙂

  2. Pingback: #133 – Where a Dependency Property Gets Its Value « 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: