SimarRajput 0 Newbie Poster

I am making an application where i am opening wpf pages in tab control. But i am able to open same page again and again in tabcontrol. I want that if once page is opened it cant be opened again and it should get focused on tabcontrol if i try to open it again. i did following code but not working.

 private void Set_Fee_Click(object sender, RoutedEventArgs e)
        {
            // Adding page to frame and then adding that frame to tab item and then adding tab item to main tab.
            FeeStructure feePage = new FeeStructure();
            _closableTab = new ClosableTabItem();
            _formFrame = new Frame();
            _formFrame.Content = feePage;
            _closableTab.Content = _formFrame;
            _closableTab.Header = "Set Fee Structure";
            if (!mainTab.Items.Contains(_closableTab))
            {
                mainTab.Items.Add(_closableTab);
                _closableTab.Focus();
            }
            else
            {
                _closableTab.Focus();
            }
        }

        private void Database_RecoveryBackup_Click(object sender, RoutedEventArgs e)
        {
            // Adding page to frame and then adding that frame to tab item and then adding tab item to main tab.
            DbRecoveryBackup dbRecBack = new DbRecoveryBackup();
            _closableTab = new ClosableTabItem();
            _formFrame = new Frame();
            _formFrame.Content = dbRecBack;
            _closableTab.Content = _formFrame;
            _closableTab.Header = "Data Base";
            if (!mainTab.Items.Contains(_closableTab))
            {
                mainTab.Items.Add(_closableTab);
                _closableTab.Focus();
            }
            else
            {
                _closableTab.Focus();
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.