jeremychan
jeremychan

Reputation: 4459

Change tab on button click event

i would like to change to a different tab when i click a button. my xaml is as follow:

<TabControl Name="Tabcontrol1" Margin=" 5" SelectedIndex="0">
            <TabItem Header="Properties" Opacity="1">
                <Grid Width="1185" Height="945" Background="Snow" >
</Grid>
</TabItem>
<TabItem Header="Others">
<Grid>
</Grid>
</TabItem>
</TabControl>

and my button click event:

    private void BuildButton_Click(object sender, RoutedEventArgs e)
{
    Tabcontrol1.SelectedIndex = "1";
}

is there something wrong? "Cannot implicitly convert type 'string' to 'int'" appears

Upvotes: 0

Views: 1954

Answers (1)

Sergey Vedernikov
Sergey Vedernikov

Reputation: 7744

Remove quotes: Tabcontrol1.SelectedIndex = 1;

Upvotes: 2

Related Questions