如果你想在分組框內標籤是一個更小的尺寸,一切都在組框相匹配的分組框標題文本大小一樣,使用樣式:
<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>
如果你想組框標題是從分組框中的所有文本不同,使用一個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中的所有其他文本。