3
我在網格中有一個標籤,我從資源字典中將樣式應用於它。風格的變化,除其他事項外,標籤的字號屬性到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屬性,它在設計器中查看時也會增加,但它永遠不會相同。這是爲什麼發生?
謝謝!我不敢相信我沒有想到這一點。 – 2012-01-14 09:54:13