Click here to Skip to main content
15,883,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tab in WPF which has many tab items, in ribbon bar there is two button 'NEXT''PREVIOUS'.

My question is, how do I navigate tabs when clicking on the button in ribbon bar...

You can increment/decrement tabcontrol.selectedIndex for next and previous click events
something like
tabcontrol.selectedIndex = tabcontrol.selectedIndex+1; (for  next button click event)
tabcontrol.selectedIndex = tabcontrol.selectedIndex -1; (for previous button click event)
Share this answer
The TabControl has a SelectedItem property which can be used to get or set the currently selected TabItem. Thus, you can use an int field to keep track of the currently selected tab, and in the Next button's event handler, just increase the int field by one and set the SelectedTab property to the corresponding index

currentIndex += 1;
myTabControl.SelectedTab = myTabControl.Items[currentIndex];

And vice versa for the Previous button.

Hope this helps
Share this answer
Naz_Firdouse 3-Jan-14 5:29am    
I believe it should be
currentIndex += 1;
myTabControl.SelectedTab = myTabControl.Items[currentIndex];
Wayne Gaylard 3-Jan-14 5:30am    
You are right of course. Thanks for that !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900