views:

783

answers:

2

Hello,

After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet HorizontalContentAlignment does not. I have also seen the other thread in this forum which points out that the DP Precedence list does not include value inheritance (http://msdn.microsoft.com/en-us/library/cc265148(VS.95).aspx#listing).

Furthermore, it seems that it is not possible to even apply Inheritable metadata to any custom DP, so it seems the silverlight framework has custom hacked it in for specific properties. I need to know exactly which dependancy properties do indeed support property value inheritance. If I have missed an obvious article on this, or a thread, then I apologize but I have been pretty thorough in my search.

Thanks.

+2  A: 

You mention that the Font properties support this so I did a little digging in reflector and found this interesting:

TextBlock

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x40003714, typeof(double));

Control

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x80003714, typeof(double));

Inline

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x3714, typeof(double));

So all three of those classes define a FontSizeProperty and the id used look very similar as if that first bit is just a flag of some kind. So perhaps there is something going on under the covers that allows what you're calling property inheritance since the the framework might transfer the values between these similar dp ids.

Bryant
+2  A: 

See the "Dependency Property Information" section of the MaxHeight (which does not inherit parent's value) and FontSize (which does propagates as you describe):

MaxHeight

FontSize


From MSDN webpage:

Property Value Inheritance

An element can inherit the value of a dependency property from its parent in the tree.

Note:

Property value inheritance behavior is not globally enabled for all dependency properties, because the calculation time for inheritance does have some performance impact. Property value inheritance is typically only enabled for properties where a particular scenario suggests that property value inheritance is appropriate. You can determine whether a dependency property inherits by looking at the Dependency Property Information section for that dependency property in the SDK reference.