I have a simple application. When you click a button, the tasbar icon changes. When I Run this app from visual studio, everything works fine, but when I publish the WPF app, the taskbar Icon does not work (there is none).
The build action is set to "embedded resource/copy always", I have tested "Resource" as well but it doesn't work.
var iconUri = new Uri("pack://application:,,,/images/internet_connection.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);
the icon in the top left corner of the frame changes, but the one in the taskbar doesn't.
Can anyone help me please ?
@Edit,
I got it to work thanks to @Pavel's comment. But now one problem remains:
When I run it in visual studio, and I do this:
var iconUri = UriHelper.GetUri(this.GetType(), "images/local_network.ico");
this.Icon = BitmapFrame.Create(iconUri);
The Icon changes. But with the published version, it doens't change.
@@Edit,
Ok so this is my code when I press a button:
var iconUri = UriHelper.GetUri(this.GetType(), "images/internet_connection.ico");
this.Icon = BitmapFrame.Create(iconUri);
mNotifyIcon = new NotifyIcon
{
BalloonTipText = "The app has been minimised. Click the tray icon to show.",
BalloonTipTitle = "The App",
Text = "The App",
Icon = BitmapFrame.Create(iconUri)
};
BitmapImage image = new BitmapImage();
image.BeginInit();
image.UriSource = UriHelper.GetUri(this.GetType(), "images/internet_connection.png");
image.EndInit();
TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo() { Overlay = image };
what does it do: When running from VS: the icon in the taskbar changes, the overlay works, the icon in the top corner of the application changes.
After build running the exe: the icon in the taskbar DOES NOT change, the overlay works, the icon in the top corner of the application changes.
Can anyone explain this ?