Groupbox in WPF can contain only one item?

It seems that a GroupBox can only contain one element, if I put more than one, it will not go inside (or will not be deleted in the blend).

Is it design or am I doing something wrong?

+62
c # wpf groupbox
Aug 31 '09 at 6:10
source share
4 answers

That sounds right to me. You will need to place the Grid or Panel (StackPanel, WrapPanel, etc.) as a child of the layout definition.

+98
Aug 31 '09 at 6:14
source share

Yes, in WPF GroupBox will contain a maximum of 1 element. You can include the Grid as your child, and in the grid - specify the necessary components. For example, 1 placed two buttons in a GroupBox using a Grid.

The structure of the document is shown below:

Document outline

The code is as follows:

<GroupBox Header="Read Sensor" HorizontalAlignment="Left" Margin="485,4,0,0" VerticalAlignment="Top" Height="188" Width="238"> <Grid HorizontalAlignment="Left" Height="169" Margin="0,0,-13,-3" VerticalAlignment="Top" Width="229"> <Button x:Name="btnReadSensor1" Content="Read Sensor 1" HorizontalAlignment="Left" Margin="10,91,0,0" VerticalAlignment="Top" Width="207" Click="btnReadSensor1_Click" /> <Button x:Name="btnReadSensor2" Content="Read Sensor 2" HorizontalAlignment="Left" Margin="10,64,0,0" VerticalAlignment="Top" Width="207" Click="btnReadSensor2_Click" /> </Grid> </GroupBox> 
+6
Jun 26 '15 at 8:34
source share

Well, the real answer is because groupbox inherits from HeaderedContentControl

Look here MSDN

+5
Nov 10 '11 at
source share

You must drag the items: the text box to the group box and should have only one group box. You cannot drag more than one group box onto a linear coordinate to make it work. May have several group mailboxes per page, but no more than one column, or you will be limited to only adding one item to the group mailbox.

-one
Aug 09 '10 at 18:53
source share



All Articles