Reputation: 1528
Is there a mechanism that is blocking the inheritance of DependecyProperty or some values are set locally by some elements?
I have two examples that I don't understand:
<Button Background="AntiqueWhite" Height="40" Width="50" FontSize="10">
<Button>Test</Button>
</Button>
<TextBlock Text="Test" Background="AntiqueWhite" Height="40" Width="50" FontSize="10">
<TextBlock />
</TextBlock>
In Button element the child button is not inheriting background / height / width but it is inheriting fontsize even though all of the properties are DependencyProperty.
In TextBlock element situation is the same but we have another DependencyProperty (Text).
I understand how priorities work. Local value has greater priority over Inherited one. But where can i get information if a control sets something by itself? Or maybe there is some other mechanism that is preventing some DependencyProperties from being inherited?
Upvotes: 0
Views: 107
Reputation: 6490
See this article: http://msdn.microsoft.com/en-us/library/vstudio/ms751554%28v=vs.100%29.aspx
DependencyProperties
have PropertyMetadata
(relevant class is FrameworkPropertyMetadata
)
One of the flags described is the Inherits
flag (http://msdn.microsoft.com/en-us/library/vstudio/system.windows.frameworkpropertymetadata.inherits%28v=vs.100%29.aspx)
Excerpt:
Inherits. By default, dependency properties do not inherit values. OverridesInheritanceBehavior allows the pathway of inheritance to also travel into a visual tree, which is necessary for some control compositing scenarios. NoteNote
The term "inherits" in the context of property values means something specific for dependency properties; it means that child elements can inherit the actual dependency property value from parent elements because of a WPF framework-level capability of the WPF property system. It has nothing to do directly with managed code type and members inheritance through derived types. For details, see Property Value Inheritance.
Upvotes: 1