XAML <GropuBox /> element represents groupbox control in WPF. The GroupBox control allows you to visually group content and provide a title for grouped elements. In title bar we can display expand/collapse button allowing you temporarily hide the content. Groupbox control is derived from ContentControl which have single element in his body. In simple word we can say GroupBox is used to represent a container that has both a single element content and single element header. In this demonstration I will show you how to use GroupBox control in WPF.

The following code snippet represents use of group box control
<GroupBox Header="Select Your Course" Height="258" HorizontalAlignment="Left" Margin="65,51,0,0" Name="groupBox1" VerticalAlignment="Top" Width="381">
                <CheckBox Content="GNIIT Software Track" Height="16" HorizontalAlignment="Left" Margin="56,27,0,0" x:Name="chkGniitcourse" VerticalAlignment="Top" />
                <CheckBox Content="B.Sc.(I.T.) Degree Program" Height="16" HorizontalAlignment="Left" Margin="56,61,0,0" x:Name="chkBscitCourse" VerticalAlignment="Top" />
                <CheckBox Content="DNIIT Diploma Program" Height="16" HorizontalAlignment="Left" Margin="56,95,0,0" x:Name="chkDniitCourse" VerticalAlignment="Top" />
                <CheckBox Content="Hardware And Networking" Height="16" HorizontalAlignment="Left" Margin="56,130,0,0" x:Name="chkHardwareCourse" VerticalAlignment="Top" />
                <Button Content="Ok" Height="23" HorizontalAlignment="Left" Margin="56,169,0,0" x:Name="btnCourse" VerticalAlignment="Top" Width="253" />
In the following code snippet we mention following points.
  •  Name—Name property is used to provide a unique name to your group box control.
  •  Header—Header property is used to provide heading to your group box control.

In this group box control I had added 4 check box and one button control.

Output of the following code snippet is as follows

GroupBox control in WPF


  Modified On Mar-22-2018 06:15:11 AM

Leave Comment