title: How to add WPF page to tabcontrol?
body: <p>I have this main wpf window
  <img src="https://i.stack.imgur.com/4D68Y.png" alt="Main WPF window"></p>
  
  <p>and this WPF page</p>
  
  <p><img src="https://i.stack.imgur.com/aFbnv.png" alt="WPF page"></p>
  
  <p>I need to add this page to tabcontrol in main window</p>
  
  <p>This is my OnRender method</p>
  
  <pre><code>   protected override void OnRender(DrawingContext drawingContext)
      {
          if (ISFirstRender)
          {
              TabItem tabitem = new TabItem();
              tabitem.Header = "Tab 3";
              pan1.Items.Add(tabitem);
              Page1 page1 = new Page1();
              tabitem.Content = new Page1();
  
              ISFirstRender = false;
          }
  
          base.OnRender(drawingContext);
      }
  </code></pre>
  
  <p>after the application running I faced this exception while selecting the new tab 
  <img src="https://i.stack.imgur.com/vQTTI.png" alt="Main WPf window after add tab3"></p>
  
  <p><img src="https://i.stack.imgur.com/H72Ku.png" alt="Error after select tab 3"></p>
  
  <p>I need to know how to add wpf page to existing tabcontroll </p>