Use a GroupBox control to create a container for a TabControl. : TabControl « Windows Presentation Foundation « VB.Net






Use a GroupBox control to create a container for a TabControl.

Use a GroupBox control to create a container for a TabControl.
     

<Page x:Class="GroupBoxExample.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="OnLoad" Name="GroupBoxPage">

    <DockPanel>
        <GroupBox Width="300" Height="410">
            <GroupBox.Header>
                <Label>Title of the GroupBox</Label>
            </GroupBox.Header>
            <StackPanel>
                <TabControl Name="myTabControl" TabStripPlacement="Top" Margin="0, 0, 0, 10" Height="350">
                    <TabItem Name="PersonalInfo">
                        <TabItem.Header>_Personal</TabItem.Header>
                        <StackPanel>
                            <TextBlock>Employee</TextBlock>
                            <TextBlock>Select your name</TextBlock>
                            <ListBox Name="empName" SelectionChanged="updateSummary">
                                <ListBoxItem IsSelected="true">A</ListBoxItem>
                                <ListBoxItem>B</ListBoxItem>
                                <ListBoxItem>C</ListBoxItem>
                                <ListBoxItem>D</ListBoxItem>
                            </ListBox>
                        </StackPanel>
                    </TabItem>
                    <TabItem>
                        <TabItem.Header>_Job</TabItem.Header>
                        <StackPanel>
                            <TextBlock>Select a job</TextBlock>
                            <ListBox Name ="job" SelectionChanged="updateSummary">
                                <ListBoxItem IsSelected="true">A</ListBoxItem>
                                <ListBoxItem>B</ListBoxItem>
                                <ListBoxItem>C</ListBoxItem>
                                <ListBoxItem>D</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>
    </DockPanel>
</Page>

//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace GroupBoxExample
  Public Partial Class Page1
    Inherits Page
    Private Sub displayData()
      Dim lbi As ListBoxItem = TryCast(empName.SelectedItem, ListBoxItem)
      emp.Text = "Name: " & lbi.Content.ToString()
      lbi = TryCast(job.SelectedItem, ListBoxItem)
      ejob.Text = "Job: " & lbi.Content.ToString()
      eskill.Text = "Skill: " & lbi.Content.ToString()
    End Sub
    Private Sub OnLoad(sender As Object, e As RoutedEventArgs)
      displayData()
    End Sub
    Private Sub updateSummary(sender As Object, e As RoutedEventArgs)
      If GroupBoxPage.IsLoaded Then
        displayData()
      End If
    End Sub
    Private Sub goToSummaryTab(sender As Object, e As RoutedEventArgs)
      displayData()
      Summary.IsSelected = True
    End Sub
  End Class
End Namespace

   
    
    
    
    
  








Related examples in the same category

1.TabPanel with TabControlTabPanel with TabControl
2.Display Content in a Multitabbed User InterfaceDisplay Content in a Multitabbed User Interface
3.Tab Controls and TabItemTab Controls and TabItem
4.Bind a TabControl to a data sourceBind a TabControl to a data source