Partager via


TabControl.SelectionChanged Event

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Occurs when the selected TabItem changes.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)

Syntax

'Declaration
Public Event SelectionChanged As SelectionChangedEventHandler
public event SelectionChangedEventHandler SelectionChanged
<sdk:TabControl SelectionChanged="eventhandler"/>

Examples

The following event handler responds to a change in the selection of a TabControl by making the same change to the selection of another TabControl. This code is part of a larger example available in the TabControl class overview.

'This handler responds to the user changing the selected 
'TabItem on tab2 by changing the selection on tab1 to 
'match. 
Private Sub tab2_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Handles tab2.SelectionChanged
    'Set the selected TabItem of tab1 to match tab2. 
    tab1.SelectedIndex = tab2.SelectedIndex
    'You can also use SelectedItem to progamatically set the 
    'selected TabItem. 
End Sub
//This handler responds to the user changing the selected
//TabItem on tab2 by changing the selection on tab1 to
//match.
void tab2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    //Set the selected TabItem of tab1 to match tab2.
    tab1.SelectedIndex = tab2.SelectedIndex;
    //You can also use SelectedItem to progamatically set the 
    //selected TabItem.
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.