none
How can we change the header font color of WPF group box??

    Question

  •  I have a groupbox with header called <My Steup>, I would like to know if there is any way to change <My Setup> color to RED

    <GroupBox Grid.Column="1" Grid.Row="1" Header="My Setup"

    Name="groupBox1" BorderBrush="Green" Background="Transparent" BorderThickness="2">

    ...
    ...
    </GroupBox>


    Thanks
    Pa Ji

    Monday, August 18, 2008 9:59 PM

Answers

  • i think this should work too:

     <GroupBox Width="300" Height="410">

        <GroupBox.Header>

          <Label Foreground="Red">My Group Header Label</Label>

        </GroupBox.Header>

    ...

    </GroupBox>



    Evan Chua-Yap

    • Marked as answer by BS-786 Tuesday, August 19, 2008 1:41 PM
    • Edited by Evan Chua-Yap Wednesday, October 01, 2008 1:22 AM
    Tuesday, August 19, 2008 12:04 AM

All replies

  • You need to modify the HeaderTemplate to achieve this, the following code runs correctly on my machine, hope it helps:
     
            <GroupBox Header="My Setup">  
                <GroupBox.HeaderTemplate> 
                    <DataTemplate> 
                        <TextBlock Text="{Binding}" Foreground="Red" HorizontalAlignment="Stretch" /> 
                    </DataTemplate> 
                </GroupBox.HeaderTemplate> 
            </GroupBox> 

    Best Regards.
    Sean
    • Edited by Shuxing Monday, August 18, 2008 11:29 PM typo
    Monday, August 18, 2008 11:28 PM
  • i think this should work too:

     <GroupBox Width="300" Height="410">

        <GroupBox.Header>

          <Label Foreground="Red">My Group Header Label</Label>

        </GroupBox.Header>

    ...

    </GroupBox>



    Evan Chua-Yap

    • Marked as answer by BS-786 Tuesday, August 19, 2008 1:41 PM
    • Edited by Evan Chua-Yap Wednesday, October 01, 2008 1:22 AM
    Tuesday, August 19, 2008 12:04 AM
  • This will also do:

            <GroupBox Header="Customer Details">  
                <GroupBox.Style> 
                    <Style TargetType="GroupBox">  
                        <Setter Property="Foreground" Value="Red"/>  
                    </Style> 
                </GroupBox.Style> 
            </GroupBox> 
     
    Tuesday, August 19, 2008 5:10 AM
  • Thanks, it worked

    Pa Ji
    Tuesday, August 19, 2008 1:41 PM