The XAML(Extensible Application Markup Language) <GropuBox /> element represents GroupBox control in WPF. The GroupBox control allows you to visually group content and provides a title for grouped elements. In the title bar, we can display the expand/collapse button allowing you to temporarily hide the content. Groupbox control is derived from
ContentControl which has a single element in his body. In simple words, we can say GroupBox is used to represent a container that has both single element content and a single element header. In this demonstration, I will show you how to use GroupBox control in WPF.
The following code snippet represents the 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">
<Grid>
<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" />
</Grid>
</GroupBox>
In the following code snippet, we mention the 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 checkbox and one-button control.
The output of the following code snippet is as follows
Anonymous User
26-Mar-2019Thanks for the guidance.