Silverlight Quick Tip: How to change Tab Items order

Monday, May 18, 2009

I’ve got a question from my colleague about how he could change the order of Tab Items according to some business logic. When adding the TabItem to the Tab control dynamically (from code behind for example) the TabItems will be added in the order they added. Here is the simple solution of hot change the order of already added tabs. In my case I have simple XAML with Tab Control: <controls:TabControl Width="400" Height="200" x:Name="tabs" Margin="5"> <controls:TabItem Header="Tab #1"> <controls:TabItem.Content> ... </controls:TabItem.Content> </controls:TabItem> ...