【发布时间】:2012-02-10 07:02:09
【问题描述】:
我在网格中有一个标签,我从资源字典中应用了一个样式。样式更改,除其他外,标签的 FontSize 属性为 14。
<Style x:Key="lblForm" TargetType= "{x:Type Label}">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,6,0"/>
</Style>
我通过以下方式将样式应用于标签:
<Label x:Name="lblFirstName" Content="First name:" Style="{StaticResource lblForm}" Grid.Row="1"/>
当我在 Blend 设计器中检查相同的标签元素时,FontSize 属性不与样式中设置的相同。例如,当样式中的 FontSize 属性设置为 14 时,设计者说 FontSize 为 10.5。如果我在样式中增加 FontSize 属性,当我在设计器中查看它时它也会增加,但它永远不会相同。为什么会这样?
【问题讨论】:
标签: wpf expression-blend font-size