Although it is impossible to set the assembly icon during runtime (it is read-only), you can use NotifyIcon
to display an icon in system tray and that is fairly easy to change during runtime.
Here is an example of how to implement a NotifyIcon:
https://www.codeproject.com/Tips/627796/Doing-a-NotifyIcon-program-the-right-way
Note: Since you are using WPF, you need to include a reference to Windows.Forms in your application.
Edit: just in case the link goes dead, here some code example for Program.cs, needs an "icon" imported as resource:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MyCustomApplicationContext());
}
public class MyCustomApplicationContext : ApplicationContext
{
public static NotifyIcon trayIcon;
public MyCustomApplicationContext()
{
trayIcon = new NotifyIcon()
{
Icon = icon,
ContextMenu = new ContextMenu(new MenuItem[]
{
new MenuItem("Exit", Exit),
new MenuItem("Do something", DoSomething),
}),
Visible = true,
BalloonTipText = "My Application",
BalloonTipTitle = "My Application",
Text = "My Application Text"
};
trayIcon.Click += new System.EventHandler(trayIcon_Click);
}
private void trayIcon_Click(object sender, System.EventArgs e)
{
//Do something
}
void DoSomething(object sender, EventArgs e)
{
}
void Exit(object sender, EventArgs e)
{
// Hide tray icon, otherwise it will remain shown until user mouses over it
trayIcon.Visible = false;
Application.Exit();
}
}