当我将不同的字体设置为分组框时,子控件也设置为分组框的字体。
我必须为每个子控件设置不同的字体属性。
就像我必须将子控件Font属性设置为
<GroupBox Font Size = "14"> <Label FontWeight"Normal" ,Font Size ="8"/> <TextBox FontWeight"Normal" ,Font Size ="8"/> </GroupBox>这是设置分组框中每个孩子的字体属性的最好方法吗?
请推荐!!
发布于 2010-03-11 18:50:17
如果希望GroupBox中的标签较小,并且分组框中的其他所有内容都与GroupBox页眉文本大小匹配,请使用样式:
<GroupBox FontSize="14" Header="Header Text">
<GroupBox.Resources>
<Style TargetType="Label">
<Setter Property="FontSize" Value="8" />
<Setter Property="FontWeight" Value="Normal" />
</Style>
</GroupBox.Resources>
<StackPanel>
<Label Text="Label Text" />
<Label Text="Another Label" />
<TextBlock Text="This will match the group header" />
</StackPanel>
</GroupBox>如果希望GroupBox标头与GroupBox中的所有文本不同,请使用TextBlock作为标头,而不是字符串:
<GroupBox>
<GroupBox.Header>
<TextBlock Text="Header Text" FontSize="14" />
</GroupBox.Header>
<StackPanel>
<Label Text="Label Text" />
<Label Text="Another Label" />
<TextBlock Text="This will be the default font" />
</StackPanel>
</GroupBox>这两种技术可以组合为一种大小用于GroupBox标题,另一种大小用于标签,第三种(默认)大小用于GroupBox中的所有其他文本。
https://stackoverflow.com/questions/2422249
复制相似问题