title: How to make my WPF MainWindow a singleton?
body: <p>I want to make my MainWindow a singleton because I want to make accessing it from all other windows in my app easier. But I couldn't make it run. Here is what I did.</p>
  
  <p>As usual, I made the MainWindow contractor private, and created a <code>public static MainWindow Instance</code> property to return a static instance. When I just run it without any other changes, I got "No Source Available" error. I googled the Internet and found one related topic at <a href="http://www.netframeworkdev.com/windows-presentation-foundation-wpf/xamlc-singleton-class-80578.shtml" rel="noreferrer">http://www.netframeworkdev.com/windows-presentation-foundation-wpf/xamlc-singleton-class-80578.shtml</a>. However, I couldn't make it work as suggested there. Some suggest to make a change in MainWindow.xaml from</p>
  
  <pre><code>&lt;Window x:Class="TestApp.MainWindow"
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;Window x:Class="TestApp.MainWindow.Instance"
  </code></pre>
  
  <p>Which looks logical. However, when I did this, I got tons of compiling errors (first one says the namespace TestApp already contains a definition of 'MainWindow'.)</p>
  
  <p>I found many articles on the Internet about how to make single instance app. I'm not looking for this. I just want to make my MainWindow a singleton. I have done it in WinForm apps many times.</p>