13

Hi I have two questions.

  1. How do I programatically change the selected tab in a WPF Tab control from one tab to another.
  2. How would I get a reference to this "other tab" in which I want to set the selected tab?

1 Answers1

28
  1. Use SelectedIndex or SelectedItem or by changing the value of the property to which those properties are bound
  2. If you're using SelectedIndex, you don't need a reference to the tab. If you're using SelectedItem, you need a reference to the data item for that tab - not the tab itself. If you've bound one of those properties to another property, you change that property rather than changing the property on the TabControl.
Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
  • 3
    One minor thing - If you are setting this inside a mouse event and no Click() event is available, use a mouse UP event and not a DOWN event. It will not work if you set the SelectedIndex inside a down event where the event is contained in the TabControl. – Paul Apr 02 '13 at 15:16