有人请教我在这里钓鱼......
我刚刚学习Silverlight,并遇到了一些实际使用的字体大小与我预期的完全不同的情况。我可能缺少一些概念性的东西。
案例A
在一个实例中,我定义了一个用户控件,它显示了一个Label来显示文本。如果单击标签,则标签(在堆栈面板中,在用户控件中)将替换为TextBox。当在页面顶部使用时(如下面的示例中使用lblName),标签文本非常小(大约8个点)。单击时,替换标签的文本框使用指定的字体大小。在应用程序的不同部分使用的相同用户控件对Label和TextBox使用相同的字体。
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="33" />
<RowDefinition Height="267*" />
</Grid.RowDefinitions>
<StackPanel Height="Auto" HorizontalAlignment="Left" Name="stackPanel" VerticalAlignment="Top" Width="Auto" Grid.Row="1" />
<my:EditLabel Height="33" HorizontalAlignment="Left" x:Name="lblName" VerticalAlignment="Top" Width="Auto" FlexText="{Binding Name, Mode=TwoWay}" FontSize="20" MinHeight="24" />
</Grid>
案例B
按下按钮时,我正在使用LiquidMenu.Menu控件弹出菜单。与我的其他页面相比,字体看起来很大(可能是36分?)。我试着通过明确地将它设置为8pt来强迫它变得非常小,但这没有效果。
<Grid x:Name="LayoutRoot" Background="{x:Null}">
<StackPanel x:Name="labelStackPanel" Orientation="Horizontal">
<TextBlock Height="24" HorizontalAlignment="Left" Name="labelText" VerticalAlignment="Top" Width="200" Text="(Value Goes Here)" />
</StackPanel>
<liquidMenu:Menu x:Name="popupMenu" Canvas.Left="40" Canvas.Top="40" ItemSelected="MenuList_ItemSelected" Visibility="Collapsed" Height="Auto" FontSize="8">
<liquidMenu:MenuItem ID="delete" Icon="Images/Delete10.png" Text="Delete" Shortcut="Del" />
<liquidMenu:MenuItem ID="exclusive" Icon="" Text="Exclusive" Shortcut="Ctrl+E" />
<liquidMenu:MenuItem ID="properties" Icon="" Text="Properties" Shortcut="Ctrl+P" />
</liquidMenu:Menu>
</Grid>
这些特定问题的答案很棒,是一种思考这类问题的新方法,以便我了解如何控制字体大小更好。