WPF JumpTask different icon than default?

I am using a WPT JumpTask object, and I would like my jumplist icon for Windows 7 to be the icon from my own application, but not by default. Other.

So how do I do this? I assume that I am specifying a different icon resource index.

But how can I store my icons as resources, and how do I know which icon is an index?

+4
source share
2 answers

According to MSDN

The icon used with JumpTask must be accessible as its own resource.

you can only load icons from a separate resource file. So, you need to set the IconResourcePath property in the DLL using the icons. If you have few icons, use the IconResourceIndex property to specify the one you need.

For example, the following code

 <Application x:Class="YourApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <JumpList.JumpList> <JumpList> <JumpTask Title="TargetApp" Description="JumpTask to start TargetApp" ApplicationPath="TargetApp.exe" IconResourcePath="LibWithIcons.dll" IconResourceIndex="2" /> </JumpList> </JumpList.JumpList> </Application> 

will create a JumpList and set the JumpTask TargetApp element third (zero numbering) from LibWithIcons.dll. By the way, if JumpTask launches another application, usually IconResourcePath installed in the executable file of this application, therefore the icon is displayed:

 <JumpTask Title="TargetApp" Description="JumpTask to start TargetApp" ApplicationPath="TargetApp.exe" IconResourcePath="TargetApp.exe" IconResourceIndex="0" /> 

How to create a DLL icon described on MSDN forums .

+2
source

It searches for your icons in a Win32 resource, which is very different from a managed resource. Take a look at this great post to understand them - you can create them and specify the order of the icons.

Insert icons into a WPF application as a resource

In the end, I used a great tool created by Einar Eigilson, which allows you to add icons as a resource in an event after assembly.

It is also worth noting that I could not display the icons when working in debug mode, regardless of what I did. Even the win32 static resource attachment did not show a single icon behind the main icon. Try testing in Release before you pull your hair out like me.

+1
source

Source: https://habr.com/ru/post/1344358/


All Articles