Reputation: 1952
I have set up a JumpList in my WPF Application.
The JumpList is fully functional apart from the Icons are not displaying, this is what I am seeing in my Taskbar:
Here is the code I have to create the JumpTask:
using System.Windows.Shell;
public JumpTask BuildJumpTask
{
get
{
return new JumpTask
{
Arguments = Argument,
ApplicationPath = Assembly.GetEntryAssembly()?.Location,
Description = GenerateDescription(),
IconResourcePath = GetIconPath(),
Title = Name
};
}
}
Private string GetIconPath()
{
return Type switch
{
JumpListItemType.About => Path.GetFullPath(@"Assets\Icons\JumpList\About.ico"),
JumpListItemType.Help => Path.GetFullPath(@"Assets\Icons\JumpList\Help.ico"),
JumpListItemType.Quit => Path.GetFullPath(@"Assets\Icons\JumpList\Quit.ico"),
JumpListItemType.Settings => Path.GetFullPath(@"Assets\Icons\JumpList\Settings.ico"),
JumpListItemType.Sign_Out => Path.GetFullPath(@"Assets\Icons\JumpList\Sign_Out.ico"),
_ => null!
};
}
All .ico files are being output to the expected directory,
I am using the following Properties for them files:
Build Action: Embedded resource (I have also tried Content)
Copy to Output Directory: Copy if newer
Upvotes: -1
Views: 141
Reputation: 155708
The documentation for JumpTask.IconResourcePath
states (emphasis mine):
https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.jumptask.iconresourcepath
The path to a resource that contains the icon. The default is
null
.
[...] An icon used with aJumpTask
must be available as a native resource.
Therefore you cannot specify the path to a PNG file for the JumpList icon - this makes sense because Win32 Icons support multiple sizes (e.g. high DPI, large icons, etc) instead of single images - you can't do that with a PNG file.
Fortunately you don't need to fire-up VisualC++ just to build a .dll
file containing a handful of icons: this QA has instructions for how to add multiple .ico
files as native ICON
/ICONDIRECTORY
resources: Adding multiple Icons (Win32-Resource) to .NET-Application - Note that the C# compiler -win32icon
option only lets you specify a single icon (as the application icon of the .exe
file), making it useless for this purpose.
Don't forget to ensure you include suitable icon artwork at 16x16, 24x24, and 32x32 to ensure your jump-list items look acceptable on non-96dpi displays.
Also note that Win32 native resources are an entirely distinct concept from .NET .resources
/.resx
- and also separate from WPF/XAML <ResourceDictionary>
objects too.
Upvotes: 1