다음을 통해 공유


TabControl.SelectedIndex Property

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

Gets or sets the index of the currently selected TabItem.

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

Syntax

'Declaration
Public Property SelectedIndex As Integer
public int SelectedIndex { get; set; }
<sdk:TabControl SelectedIndex="int"/>

Property Value

Type: System.Int32
The index of the currently selected TabItem, or -1 if a TabItem is not selected.

Remarks

Dependency property identifier field: SelectedIndexProperty

Examples

The following code sets the currently selected TabItem. This code is part of a larger example available in the TabControl class overview.

'Set the selected TabItem of tab1 to match tab2. 
tab1.SelectedIndex = tab2.SelectedIndex
'You can also use SelectedItem to progamatically set the 
'selected TabItem. 
//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.