How to make a GroupBox size to its content

Lloyd Sheen 1,476 Reputation points
2020-10-27T14:05:25.08+00:00

Very simple request. How do I make (or can I make) a GroupBox size to its content.

I have a groupbox which contains a number of items in a stackpanel. If I add a value then the GroupBox will not show the value. I have tried with height and width set to Auto but that does not work.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
{count} votes

Accepted answer
  1. Viorel 114.5K Reputation points
    2020-10-27T19:34:17.63+00:00

    Check an example:

    <GroupBox Margin="10,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="10">
        <StackPanel>
            <CheckBox x:Name="checkBox1" Content="CheckBox1" />
            <CheckBox x:Name="checkBox2" Content="CheckBox2" />
            <CheckBox x:Name="checkBox3" Content="CheckBox3" />
        </StackPanel>
    </GroupBox>
    
    0 comments No comments

0 additional answers

Sort by: Most helpful