Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the corners of a groupBox to sharp instead of round C# .NET WPF

I just started working with GroupBoxes and I was just wondering why I cant make my corners sharp, as if it was a rectangle. I've seen a few online and thier corners arent round. Why is that?

 <GroupBox x:Name="howTOGroupBox" BorderBrush="White" Foreground="White" Header="How To" HorizontalAlignment="Left" Margin="88,86,0,0" VerticalAlignment="Top" Height="79" Width="221" BorderThickness="1"/>

enter image description here

like image 241
Jame O. Weinburgh Avatar asked Sep 06 '25 18:09

Jame O. Weinburgh


1 Answers

you can style Your GroupBox ControlTemplate and round to 0 all of the corners:

<Window.Resources>
  <Style TargetType="GroupBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="GroupBox">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0"
                          BorderThickness="1" BorderBrush="White"
                          CornerRadius="0,0,0,0">
                            <ContentPresenter 
                          ContentSource="Header"
                          RecognizesAccessKey="True" />
                        </Border>
                        <Border Grid.Row="1" BorderBrush="White"
                                    BorderThickness="1"
                                    CornerRadius="0,0,0,0">
                            <ContentPresenter Margin="4" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
like image 170
Rom Avatar answered Sep 09 '25 07:09

Rom