title: In which window should I instantiate my object?
body: <p>My WPF application has multiple windows:</p>
  
  <ul>
  <li>MainWindow
  
  <ul>
  <li>ChildWindow1</li>
  <li>Childwindow2</li>
  </ul></li>
  </ul>
  
  <p>I instantiate the children from MainWindow by...</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      ChildWindow1 CW1;
      ChildWindow2 CW2;
  
      public MainWindow()
      {
          InitializeComponent();
      }
  
      private void btnButton1_Click(object sender, RoutedEventArgs e)
      {
          CW1 = new ChildWindow1();
          CW1.Show();
          CW1.Owner = this;
  
          CW2 = new ChildWindow2();
          CW2.Show();
          CW2.Owner = this;
      }
  }
  </code></pre>
  
  <p>Awesome! </p>
  
  <p>But here's where I run into trouble: I have a non-UI class that I need to instantiate.</p>
  
  <pre><code>public class MyClass
  {
      public void DoSomething()
      {
          //Do something here
      }
  }
  </code></pre>
  
  <p>The object of that class should "live" inside ChildWindow1, because that's where it logically belongs. So, I instantiate it inside ChildWindow1 like so:</p>
  
  <pre><code>public partial class ChildWindow1 : Window
      {
          public MyClass MyObject = new MyClass();
  
          public ChildWindow1()
          {
              InitializeComponent();
          }
      }
  </code></pre>
  
  <p>But eventually comes a point where ChildWindow2 needs to interact with the object in ChildWindow1:</p>
  
  <ol>
  <li>Call the 'DoSomething()' method of the object in Childwindow1.</li>
  <li>Subscribe to an event raised by the object in ChildWindow1</li>
  </ol>
  
  <p>I can do all that from the main window, because it owns the children, but I want the children to be able to interact directly.</p>
  
  <ul>
  <li><p>Am I violating a design principle by allowing CW1 &lt;--> CW2 interaction?</p></li>
  <li><p>How else would you get them to interact if not by calling methods or subscribing to events?</p></li>
  </ul>
  
  <p>Thanks to all here, for providing this awesome learning resource! Much appreciated!</p>