I am trying to create an wpf app and I want to minimize it to system tray, I followd this question and created the following window
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = new System.Drawing.Icon("Main.ico");
ni.Visible = true;
ni.DoubleClick +=
delegate (object sender, EventArgs arg)
{
this.Show();
this.WindowState = WindowState.Normal;
};
}
protected override void OnStateChanged(EventArgs e)
{
if (WindowState == System.Windows.WindowState.Maximized)
this.Hide();
base.OnStateChanged(e);
}
}
however when I tried to run it visual studio opened a window saying "Thread.cs not found"
The exception says "The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception ' Line number '6' and line position '9'."
I tried to Enable "just my code" but then the app enter a break mode. Any idea what is the problem here? Is there anyway to fix it?