title: Windowless tray icon application
body: <p>OK I am a total newbie at WPF but I have to develop what's in the title with wpf but not relying on MVVM.
  I have followed this:</p>
  
  <p><a href="https://stackoverflow.com/questions/1472633/wpf-application-that-only-has-a-tray-icon">WPF Application that only has a tray icon</a></p>
  
  <p>I found the first answer the one with the hardcodet lib but find it too difficult and MVVM biased.</p>
  
  <p>So followed the second one and everything seemed fine except that in the end it doesn't work.
  So in my App.xaml.cs I have put:</p>
  
  <pre><code>public partial class App : Application
  {
      private System.Windows.Forms.NotifyIcon notifyIcon = null;
  
      protected override void OnStartup(StartupEventArgs e)
      {
        base.OnStartup(e);
        UnityCore.Initialize();
      }
  
      protected override void OnActivated(EventArgs e)
      {
        notifyIcon = new System.Windows.Forms.NotifyIcon();
        notifyIcon.Click += NotifyIcon_Click;
        notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
  
        Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/Images/ITA.png")).Stream;
        notifyIcon.Icon = new System.Drawing.Icon(iconStream);
        notifyIcon.Visible = true;
        base.OnActivated(e);
      }
  
      private void NotifyIcon_DoubleClick(object sender, EventArgs e)
      {
        Console.Beep();//show main window
      }
  
      private void NotifyIcon_Click(object sender, EventArgs e)
      {
        Console.Beep();//show main window
      }
  }
  </code></pre>
  
  <p>The main window at start is transparent of minimized to make it invisible.</p>
  
  <p>At this stage I hoped to see the ITA flag in the tray icon and then at click or double click restore the main window.</p>
  
  <p>But I don't see a damn thing in the tray.</p>
  
  <p>I think that the flag resource is properly set here's my solution</p>
  
  <p><a href="https://i.stack.imgur.com/p0Sbf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p0Sbf.png" alt="enter image description here"></a></p>
  
  <p>Thanx for any help.</p>