switching tabs on button click in wpf
<p>I have 4 tabs and clicking the button move to front it should change tabs the next one. But out of the four tabs, tab 2 is hidden and I dont want it to show. So if the screen is at tab 1, on move forward it should display tab 3 and from tab 3 it should open tab 4. Similarly on move back if it's at tab 3, it should go to tab 1 without displaying tab 2. I tried this implementation but it still goes to tab 2.</p>

<pre><code>        private void movefront_click(object sender, RoutedEventArgs e)
    {
        if (tabIUWM.SelectedIndex == 2)
        {
            TabStudyAreaInterface.Visibility = Visibility.Visible; //tabstudyareainterface is the name of tab 2
        }
        else
        {
            tabIUWM.SelectedIndex = tabIUWM.SelectedIndex + 1;
        }        

    }
    private void moveback_click(object sender, RoutedEventArgs e)
    {

        if (tabIUWM.SelectedIndex == 2)
        {
            TabStudyAreaInterface.Visibility = Visibility.Visible;

        }
        else
        {

            tabIUWM.SelectedIndex = tabIUWM.SelectedIndex - 1;
        }

        if (tabIUWM.SelectedIndex == -1)
        {
            MessageBox.Show("This is the beginning screen");
        }

    }
</code></pre>

<p>Thanks :) </p>