Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GroupBox header text is cut off

Tags:

c#

wpf

xaml

I'm trying to make a GroupBox in XAML that houses three RadioButtons. Everything looks fine except that the 'g' in my GroupBox header is cut off at the bottom, like this:

Screenshot one

I've read other posts with formatting issues, and have steered clear of positioning my different elements using margins. However, this doesn't seem to be my problem. I have built everything using grids (even inside my GroupBox), but something is still cutting my header off. Any input would be appreciated!

This is what the GroupBox looks like when the font is normal and not bold:

Screenshot two

Here is the part of my code with the GroupBox:

<Grid Grid.Row="1">
                <GroupBox Header="Current Units (English)" HorizontalAlignment="Stretch" Name="currentUnitsGroupBox" VerticalAlignment="Stretch" FontSize="12" FontWeight="Bold">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="6" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="4" />
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width=".22*" />
                                <ColumnDefinition Width=".22*" />
                                <ColumnDefinition Width=".22*" />
                                <ColumnDefinition Width=".36*" />
                            </Grid.ColumnDefinitions>
                            <RadioButton 
                                Content="System" 
                                HorizontalAlignment="Stretch" 
                                Name="systemRadio" 
                                VerticalAlignment="Center" 
                                FontSize="12" 
                                FontWeight="Bold" 
                                IsChecked="True" 
                                Grid.Column ="0" 

                                AutomationProperties.AutomationId="CurrentUnitsSystem"/>
                            <RadioButton 
                                Content="English" 
                                FontSize="12" 
                                FontWeight="Bold" 
                                HorizontalAlignment="Stretch" 
                                Name="englishRadio" 
                                VerticalAlignment="Center" 
                                Grid.Column="1" 

                                AutomationProperties.AutomationId="CurrentUnitsEnglish"/>
                            <RadioButton 
                                Content="Metric" 
                                FontSize="12" 
                                FontWeight="Bold" 
                                HorizontalAlignment="Stretch" 
                                Name="metricRadio" 
                                VerticalAlignment="Center" 
                                Grid.Column="2" 

                                AutomationProperties.AutomationId="CurrentUnitsMetric"/>
                        </Grid>
                    </Grid>
                </GroupBox>
            </Grid>
like image 413
Pine Avatar asked Jul 29 '16 20:07

Pine


1 Answers

I've tested it with everything that came to my mind and im not able to reproduce it. Please try the following:

<GroupBox FontSize="12" FontWeight="Bold"> 
    <GroupBox.Header> 
           <TextBlock Height="22" Text="Current Units (English)"/>     </GroupBox.Header>

Since the Header in the GroupBox is a TextBlock anyway, we do the stuff now by ourself and adjust the height a little bit

like image 59
lokusking Avatar answered Sep 18 '22 01:09

lokusking