public bool CloseTab(CustomTabItem tab)
 {
     if (tab == null) return false;
     if (tab.Close())
     {
         tabControl.Items.Remove(tab);
         dicTabs.Remove(tab.Tag as string);
         return true;
     }
     return false;
 }
        private CustomTabItem AddTab(string key, Page page, string Header = "")
        {
            key = key.ToUpper();
            if (dicTabs.Keys.Contains(key))
                return dicTabs[key] as CustomTabItem;

            CustomTabItem tabItem = new CustomTabItem(page);
            tabItem.Tag = key;

            tabControl.Items.Add(tabItem);
            dicTabs.Add(key, tabItem);

            return tabItem;
        }