CHANGE TAB ON BUTTON CLICK EVENT IN WPF

C G E Mannerheim

Total Post:29

Points:203
Posted by  C G E Mannerheim
WPF 
WPF
 3553  View(s)
Ratings:
Rate this:
HI  experts!

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

thanks in advance

  1. shreesh chandra shukla

    Post:105

    Points:735
    Re: Change tab on button click event in wpf

    Hi!

    try this.

    Remove quotes: Tabcontrol1.SelectedIndex = 1;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!