【发布时间】:2014-02-07 14:12:30
【问题描述】:
是否存在阻止 DependecyProperty 继承的机制,或者某些值是由某些元素在本地设置的?
我有两个不明白的例子:
<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>
在 Button 元素中,子按钮没有继承背景/高度/宽度,但它继承了字体大小,即使所有属性都是 DependencyProperty。
在 TextBlock 元素中情况是一样的,但是我们有另一个 DependencyProperty (Text)。
我了解优先事项的运作方式。本地值比继承的值具有更高的优先级。但是,如果控件自己设置某些东西,我在哪里可以获得信息?或者可能有其他机制阻止某些 DependencyProperties 被继承?
【问题讨论】:
标签: wpf xaml dependency-properties