GroupBox Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] public class GroupBox : HeaderedContentControl
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ public class GroupBox extends HeaderedContentControl
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) public class GroupBox extends HeaderedContentControl
<GroupBox> Content </GroupBox>
Content Model: GroupBox is a HeaderedContentControl and has two content properties: Header and Content. For information about how to set these properties, see Headered Content Control Content Model.
The following illustration is an example of a GroupBox that contains a TabControl and a Button that are enclosed in a StackPanel.
This example shows how to create a container by using the GroupBox control. The container has a title and a visible border that encloses its content.
The following example defines a GroupBox control that is titled My Employee Info. The control encloses a TabControl and a Button in a StackPanel. The example defines the title by setting the Header property to the Label string.
<GroupBox Width="300" Height="410"> <GroupBox.Header> <Label>Employee Data</Label> </GroupBox.Header> <StackPanel> <TabControl Name="myTabControl" TabStripPlacement="Top" Margin="0, 0, 0, 10" Height="350" > <TabItem Name="PersonalInfo"> <TabItem.Header>_Personal Info</TabItem.Header> <StackPanel> <TextBlock>Employee</TextBlock> <TextBlock>Select your name</TextBlock> <ListBox Name="empName" SelectionChanged="updateSummary"> <ListBoxItem IsSelected="true">Esther</ListBoxItem> <ListBoxItem>George</ListBoxItem> <ListBoxItem>Alan</ListBoxItem> <ListBoxItem>Eric</ListBoxItem> </ListBox> </StackPanel> </TabItem> <TabItem> <TabItem.Header>_Job Info</TabItem.Header> <StackPanel> <TextBlock>Select a job</TextBlock> <ListBox Name ="job" SelectionChanged="updateSummary"> <ListBoxItem IsSelected="true">Programmer</ListBoxItem> <ListBoxItem>Tester</ListBoxItem> <ListBoxItem>Writer</ListBoxItem> <ListBoxItem>Manager</ListBoxItem> </ListBox> </StackPanel> </TabItem> <TabItem Name="Skill"> <TabItem.Header>_Skill</TabItem.Header> <StackPanel> <TextBlock> Select your strongest skill </TextBlock> <ListBox Name="skills" SelectionChanged="updateSummary"> <ListBoxItem IsSelected="true">C#</ListBoxItem> <ListBoxItem>Visual Basic</ListBoxItem> <ListBoxItem>.NET</ListBoxItem> <ListBoxItem>JScript</ListBoxItem> </ListBox> </StackPanel> </TabItem> <TabItem Name="Summary" > <TabItem.Header>Su_mmary</TabItem.Header> <StackPanel> <TextBlock Name="emp"/> <TextBlock Name="ejob"/> <TextBlock Name="eskill"/> </StackPanel> </TabItem> </TabControl> <Button Content="Show Summary" Click="goToSummaryTab"/> </StackPanel> </GroupBox>
You must also define an event handler on a code-behind page in order to handle the Click event that occurs when a user clicks the Show Summary button.
For the complete sample, see GroupBox Sample.
More Code
| How to: Define a GroupBox Template | This example shows how to create a template for a GroupBox control. |
| How to: Create a Control That Has an Access Key and Text Wrapping | This example shows how to create a control that has an access key and supports text wrapping. The example uses a Label control to illustrate these concepts. |
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
System.Windows.Controls.ContentControl
System.Windows.Controls.HeaderedContentControl
System.Windows.Controls.GroupBox
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.