title: DataContext issue with creation of new window
body: <p>I have a problem and I'm sure it's pretty easy to sort out, but I just can't get my data context correct.</p>
  
  <p>I have a popup window with a combobox (cmbChannel). When you close the popup window, the Main Window opens, with a label showing the selected value from that combobox, in txtChannel. </p>
  
  <p>In the popup window (which can popup anytime with the click of a button), I check to see if the Main Window is open yet, then I either open it or do nothing:
  Popup.xaml.cs</p>
  
  <pre><code>//Check to see if MainWindow has been created yet
   if (App.Current.MainWindow != null &amp;&amp; App.Current.MainWindow.GetType() == typeof(MainWindow))
   {
       this.Close();
   }
   else
   {
        //main Window hasn't been created yet so create it!
        MainWindow main = new MainWindow() { DataContext = this };
        App.Current.MainWindow = main;
        this.Close();
        main.Show();
              }
  var mainwin = App.Current.Windows.OfType&lt;MainWindow&gt;().SingleOrDefault(w =&gt; w.IsActive);
  mainwin.DataContext = this; //Set again just in case
  </code></pre>
  
  <p>I make sure to set the DataContext of my MainWindow.</p>
  
  <p>Here's my popup combobox:<br>
  <code>&lt;ComboBox x:Name="cmbChannel" ItemsSource="{Binding CmbContent}" SelectedItem="1" HorizontalAlignment="Left" Margin="94,127,0,0" VerticalAlignment="Top" Width="91"/&gt;</code>
  Pretty simple. </p>
  
  <p>So now, in my main window, I thought all I had to do was this: </p>
  
  <pre><code>&lt;Label x:Name="txtChannel" Content="{Binding Path=SelectedValue, ElementName=cmbChannel}" HorizontalAlignment="Left" Margin="80,171,0,0" VerticalAlignment="Top" Width="58" /&gt;
  </code></pre>
  
  <p>But that isn't working. I'm pretty sure this is a data context problem, maybe I'm not declaring it correctly? Not sure. Any help is appreciated!</p>