WPF JumpTask除了默认图标以外还有另一个图标吗?

Mat*_*zen 5 c# vb.net wpf windows-7

我正在使用WPF JumpTask对象,并且我希望Windows 7跳转列表图标是我自己的应用程序中的图标-但不是默认应用程序图标。另一种

那么我该怎么做呢?我想我指定了另一个图标资源索引。

但是,我如何甚至将图标存储为资源,又如何知道哪个图标是哪个索引?

Kyr*_*o M 2

根据MSDN

与 JumpTask 一起使用的图标必须可作为本机资源使用。

您只能从单独的资源文件加载图标。因此,您需要IconResourcePath使用图标设置 DLL 的属性。如果您的图标很少,请使用IconResourceIndex属性来指定所需的图标。

例如,下一个代码

<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>
Run Code Online (Sandbox Code Playgroud)

将创建 JumpList 并从LibWithIcons.dll设置为 JumpTask 项TargetApp 第三个图标(基于 null 的计数)。顺便说一下,如果JumpTask启动另一个应用程序,通常会被设置为该应用程序的可执行文件,因此会显示它的图标:IconResourcePath

<JumpTask Title="TargetApp"
    Description="JumpTask to start TargetApp"
    ApplicationPath="TargetApp.exe"
    IconResourcePath="TargetApp.exe"
    IconResourceIndex="0" />
Run Code Online (Sandbox Code Playgroud)

MSDN 论坛上描述了如何创建图标 DLL 。

  • 您如何知道哪个图标位于哪个索引处?你的回答并没有说明这一点。 (2认同)