Wednesday, November 12, 2008

Silverlight - value inheritance

This post will be about value inheritance of dependency properties in Silverlight.

You cannot write custom dependency property with inheritance. There is the fixed set of predefined properties with value inheritance, for example: FontFamily, FontSize, FontStretch, FontStyle, FontWeight, Foreground.  There was a problem with performance and Silverlight team did a number of optimizations specific to those particular properties. All properties have the same precedence order:

1.  animations -> 2. local value (and binding) -> 3. templated property -> 4. style -> 5. value inheritance -> 6. default value

BTW,  Silverlight Toolkit introduces one more way to customize controls  - themesTheme  has lower priority than style, but higher than value inheritance.

No comments: