Esempio n. 1
0
        private void CreateTab()
        {
            SingleClientControl singleClient = new SingleClientControl();
            TabHeaderControl    tabHeader    = new TabHeaderControl();

            tabHeader.CloseAction = CloseTab;
            TabItem tabItem = new TabItem();

            tabItem.Content = singleClient;
            tabItem.Header  = tabHeader;
            singleClient.SetHeader(tabHeader);
            int tabItemIndex = MainTabControl.Items.Count - 1;

            MainTabControl.Items.Insert(tabItemIndex, tabItem);
            MainTabControl.SelectedIndex = tabItemIndex;
        }
Esempio n. 2
0
        private void CloseTab(TabHeaderControl tabHeader)
        {
            for (int i = 0; i < MainTabControl.Items.Count; i++)
            {
                TabItem          item             = MainTabControl.Items.GetItemAt(i) as TabItem;
                TabHeaderControl tabHeaderControl = item.Header as TabHeaderControl;
                if (tabHeaderControl != null && tabHeaderControl == tabHeader)
                {
                    if (i != 0)
                    {
                        if (MainTabControl.SelectedIndex == i)
                        {
                            MainTabControl.SelectedIndex = i - 1;
                        }
                    }

                    MainTabControl.Items.RemoveAt(i);
                    break;
                }
            }
        }