Over a million developers have joined DZone.

Resolution of Dependency Properties

DZone 's Guide to

Resolution of Dependency Properties

· ·
Free Resource

As I mentioned in my previous blog post, dependency properties depend on any number of services (called property providers) for their values. The Silverlight runtime needs to follow strict rules of precedence to determine the value of a dependency property. This process is called dynamic value resolution.

Here’s a prioritized list of providers in their order of precedence:

1. Animation: If an animation is running and is changing the property value, Silverlight uses the animated value

2. Local Value: If the property value has been explicitly set through XAML or code (by using SetValue or the property wrapper), Silverlight uses the local value.

3. Templated Properties: Silverlight uses the template properties if the object has been built dynamically from templates (ControlTemplate or DataTemplate).

4. Styles Setters: If the page or the application resource defines a Style that applies to the given element, with a Setter for its dependency property, then Silverlight assigns the value from the Setter to the dependency property.

5. Default Value: If no other property setter is at work, Silverlight assigns the default value to the dependency property. If a value is passed in through the PropertyMetadata object during dependency property registration, it will be used as the default value. If no value has been passed in, then the default value depends on the type (reference or value) used for storing that dependency property.



Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}