I have started a modal dialog from a main xaml page. when ok is click on the modal I need to add a tab to the main dialog. I tried this code but is not working. When the modal dialog is clicked, the new tab is not being added to the main page. I'm running on deadline
Please any help is very welcomed.


Main page entry

Code:
public partial class MainPage : UserControl
    {
        public MainPage()
        {
           
            InitializeComponent();
            if (((App)Application.Current).datacol.Count > 0) //checks for entry 
                                                                          //before adding tab
            {
                addNewTab();
                DataContext = this;
            }
        }
Addind tab function
Code:
  private void addNewTab()
        {
            TabItem item = new TabItem();
            item.Header = "New tab";
            this.tabCases.Items.Add(item);

        }
Pop up code
Code:
 private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            
            ((App)Application.Current).datacol.Add(new RawData());
            int ct = ((App)Application.Current).datacol.Count;
            ((App)Application.Current).RootVisual = new MainPage(); //send
                                                                           // view to main page ??
        
            this.DialogResult = true;
        }