If you want to center a group box in a WPF application, you can use the HorizontalAlignment property.

HorizontalAlignment="Center"

Make sure the margin left and margin right are 0

 

Margin="0,30,0,0"

image

 

Code

<Window x:Class="Rvl.DashBoard.Wpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Dashboard" Height="350" Width="525" WindowState="Maximized" Icon="/Rvl.DashBoard.Wpf;component/Dashboard.ico">
    <Grid>
        <GroupBox Header="Continuous Deployment" Height="107" HorizontalAlignment="Center" Name="continuousDeploymentGroupBox" VerticalAlignment="Top" Width="322" HorizontalContentAlignment="Center" Margin="0,30,0,0">
            <Grid>
                <Button Content="AKS" Height="23" HorizontalAlignment="Left" Margin="29,20,0,0" Name="aksButton" VerticalAlignment="Top" Width="75" Click="Deploy_AKS" Cursor="Hand" />
                <Button Content="LocatiePlatform" Height="23" HorizontalAlignment="Left" Margin="165,20,0,0" Name="locatiePlatformButton" VerticalAlignment="Top" Width="109" Click="Deploy_LocatiePlatform" Cursor="Hand" />
            </Grid>
        </GroupBox>
    </Grid>
</Window>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.