Style中设置的FontSize与Blend中的FontSize不匹配

Bla*_*ord 3 wpf font-size expression-blend

我在网格中有一个标签,我从资源字典中应用了一个样式.除其他外,样式将标签的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>
Run Code Online (Sandbox Code Playgroud)

我以下列方式将样式应用于标签:

<Label x:Name="lblFirstName" Content="First name:" Style="{StaticResource lblForm}" Grid.Row="1"/>
Run Code Online (Sandbox Code Playgroud)

当我检查在Blend中的设计相同的标签元素,将字号属性是相同集的风格.例如,当样式中的FontSize属性设置为14时,设计者说FontSize为10.5.如果我在样式中增加FontSize属性,当我在设计器中查看它时它也会增加,但它永远不会相同.为什么会这样?

nem*_*esv 9

您可以FontSize以不同的方式设置.来自MSDN:

<object FontSize ="qualifiedDouble"/>

qualifiedDouble如前所述的double值,后跟其中一个单位声明字符串:px,in,cm,pt.

px(默认值)是与设备无关的单位(每单位1/96英寸)

in是英寸; 1英寸== 96PX

厘米是厘米; 1cm ==(96/2.54)px

pt是积分; 1pt ==(96/72)px

在你的风格中,如果没有明确地设置它,它默认为px.但Blend用pt计算 在此输入图像描述

这就是两个值不同的原因.