title: Attempting to share Object between WPF windows
body: <p>I instantiate a class in the MainWindow of my WPF application, then pass that Object to a second window on a click event. But when I attempt to run a method of the Object I passed to the second window in the Window_Loaded method I get the error:</p>
  
  <blockquote>
    <p>The name <code>object</code> does not exist in the current context.</p>
  </blockquote>
  
  <p>This is my MainWindow code:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  
  
      Object objectName;
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
              objectName = new Object();
              objectName.Text = "text";
  
  
  
  
      }
      private void MenuItem_Click(object sender, RoutedEventArgs e)
      {
          Settings settingsWindow = new Settings(objectName);
          settingsWindow.Show();
      }
  }
  </code></pre>
  
  <p>and the SettingsWindow:</p>
  
  <pre><code>public partial class Settings : Window
  {
      public Settings(Object object)
      {
          InitializeComponent();
      }
  
      private void SettingsWindow_Loaded(object sender, RoutedEventArgs e)
      {
          // get text in object
          String name = object.Text;
      }
  }
  </code></pre>
  
  <p>So I am able to pass the Object to the Window but how can I use it in the new windows Window_Loaded method?</p>