TabControl and selected tab index

By Mirek on (tags: TabControl, WPF, categories: code)

It was obvious for me that a TabControl in WPF, which is a container for TabItems, has a dependency property indicating the index of current tab.

I was, also obviously, not surprised when I found TabIndex property on the TabControl. So without unnecessary thinking and spending time on that, I have set a binding to this property in my application. I was hoping that by changing binded property on underlying data context I will be able to change the currently visible tab in my TabControl.
Unfortunately it was a wrong way. The TabIndex property is a standard property which all visual controls have (which I should remember, since I have used this property few times in the past) and it indicates the order of focusing of controls when user hits the TAB key.
The selected tab index in TabControl is represented by SelectedIndex property, and I should choose this from the beginning.

So be careful of misleading property names next time Puszczam oczko