title: Passing Variable from one WPF Window to Another (C#)
body: <p>I really feel bad for having to ask this. The answer should probably be obvious; however, I have searched here and on Google to no avail. </p>
  
  <p>I am quite new to WPF. With Windows Forms, I recall it was quite easy to pass data between Windows, but I cannot figure it out with my WPF application.</p>
  
  <p>I am simply building an application for myself that will allow me to access and insert data in a MySQL database. When the button I have added to view all the records in a table is clicked, I want a new window to open. This window will simply display all the data; the table will be selected in MainWindow.</p>
  
  <p>The problem I have is this: I need someway for the secondary window (View) to know which table was selected. I will probably use a ListBox control for table selection, but at the end of the day it really does not matter. Eventually, the value will be stored as a string in a variable. I need the View window to be able to access this string so it knows which table to query. In example:</p>
  
  <p>// Main Window </p>
  
  <pre><code>private void viewButton_Click(object sender, RoutedEventArgs e)
      {
          var table = "DS";
                  View viewWindow = new View();
                  viewWindow.Show();                
          }
  </code></pre>
  
  <p>// View Window</p>
  
  <pre><code>private void windowLoad(object sender, RoutedEventArgs e)
      {
          DatabaseConnection myConnection = new DatabaseConnection();
          List&lt;string&gt;[] result = myConnection.Select(table);
  
          text.Text = MainWindow.test + (result[0][0] + " " + result[1][0] + " " + result[2][0] + " " + result[3][0]);
  
      }
  </code></pre>
  
  <p>All I need to do is to pass the value of table (which will vary in the final application based on user input), to View. For example, I need it so that in the above code, the following would be executed:</p>
  
  <pre><code>List&lt;string&gt;[] result = myConnection.Select("DS");
  </code></pre>
  
  <p>I feel like this should be obvious and easy, but I am not sure how to accomplish this. I would sincerely appreciate any help.</p>