Tabs Studio Blog (organizing Visual Studio document tabs)

August 22, 2009

Internal tab order

Filed under: Uncategorized — Tags: — Sergey Vlasov @ 8:43 am

Tab order in Tabs.TabPanel and Tabs.TabList can be different. By default a new tab is added to the end of both TabPanel and TabList. After that tabs can be reordered in TabPanel, manually using drag’n’drop or automatically using Sorter like add-in. Order in TabList remains constant. If it is important to handle tabs the way a user sees it then process them in TabPanel order.

To find TabItem in TabPanel having TabsStudioExt.Tab just use the Tab.TabItem property. To find TabsStudioExt.Tab having TabItem in TabPanel use function like this:

private TabsStudioExt.Tab FindTabByItem(System.Windows.Controls.TabItem tabItem, TabsStudioExt.Tabs tabs)
{
    foreach(TabsStudioExt.Tab tab in tabs.TabList)
    {
        if (tab.TabItem == tabItem)
            return tab;
    }
    return null;
}

You can sort TabList according to TabPanel ordering and then work with TabList collection having sure tab order is in the way a user sees it:

tabList.Sort(
    delegate(TabsStudioExt.Tab lhs, TabsStudioExt.Tab rhs)
    {
        return tabs.TabPanel.Children.IndexOf(lhs.TabItem).CompareTo(
                    tabs.TabPanel.Children.IndexOf(rhs.TabItem));
    });

Blog at WordPress.com.

%d bloggers like this: