Change active tab of Tabs component

Hi - I'm trying to set the active tab on the Tabs component. I tried using .selectedIndex but that only sets the initial tab. It works in code as long as the user has not clicked a tab. If the user clicks on a tab, changing the .selectedIndex property is no longer picked up by the Tabs component. Any idea how I can set the active tab using code?

Hi @BobJ,

The SelectedIndex property should be used indeed. You however need to keep it in sync with the TabStrip state. Here is an example.

  1. Create a page property and set it to 0.
  2. Set the SelectedIndex property of the Tabs to that page property.
  3. Handle the Change event of the Tabs to sync the page property with the currently selected tab index.
  4. Update the property (for example from the click event of a button) to set the current selection.

Here is how it works.

2 Likes

Works like a charm - thank you!!!