How to set the font of a child control in a group field?

When I set a different font in the Group field, the child controls also set the font of the group window.

I need to set each child control with a different font property.

How should I set the Font property of a child control to

<GroupBox Font Size = "14"> <Label FontWeight"Normal" ,Font Size ="8"/> <TextBox FontWeight"Normal" ,Font Size ="8"/>  </GroupBox>

Is this the best aprroach to set the font property for each child within a group field?

Please suggest !!

+3
source share
1 answer

If you want the labels in the GroupBox to be smaller and everything else in the group field to fit the size of the text of the GroupBox header, use the style:

<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.

+3

Source: https://habr.com/ru/post/1736416/


All Articles