title: WPF ContextMenu for tray icon
body: <p>I'm having a WPF application which I can minimize to tray. When I normal-click it, the window shows again. </p>
  
  <p>Now I'm wondering how to create a simple <code>ContextMenu</code>?</p>
  
  <p>The <code>ContextMenu</code> has to get filled with x options which onclick will run a function. For now I just need an 'Exit'-item linked to an 'Exit_Click' method.</p>
  
  <p>Something I've tried is:</p>
  
  <pre><code>ContextMenu menu = (ContextMenu)this.FindResource("NotifierContextMenu");
  menu.IsOpen = true;
  </code></pre>
  
  <p><code>menu</code> doesn't know of any <code>IsOpen</code> value.</p>
  
  <p>Other examples like to use a lot of different things. <a href="https://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/#eleventh" rel="nofollow">One of them requires me to create a HostManager for some reason.</a></p>
  
  <p>I just need a simple <code>ContextMenu</code>. How can I achieve this?</p>