title: How can I access a parameter in a constructor new window?
body: <p>I want to pass a variable as a parameter from my main window to a new one.</p>
  
  <p>Actually, I can access parameter in an event handler of the new window, but not in the constructor.</p>
  
  <p>mainwindow.xaml.cs :</p>
  
  <pre><code>                string selectedKey = “test”;
                  EditTri editTri = new EditTri();
                  editTri.key = selectedKey;
                  editTri.ShowDialog();
  </code></pre>
  
  <p>EditTri.xaml.cs:</p>
  
  <pre><code>public partial class EditTri : Window
      {
  
          public string key;
  
  
          public EditTri()
          {
              InitializeComponent();
  
           MessageBox.Show(key);  //key = null ...
  
          }
  
          private void buttonEdit_Click(object sender, RoutedEventArgs e)
          {
  
              MessageBox.Show(key);   //key = test
  
              this.Close();
          }
  
      }
  </code></pre>
  
  <p>I just need to access the parameter <code>key</code> in constructor <code>EditTri()</code>. How can I do this?</p>