Windows API代码包TaskDialog缺少图标

jac*_*obz 3 c# windows icons windows-api-code-pack

我的图标TaskDialog丢失了:

在任务栏中:

我的代码是这样的:

using Microsoft.WindowsAPICodePack;
using Microsoft.WindowsAPICodePack.Dialogs;

...

TaskDialog taskDialog = new TaskDialog();
taskDialog.Caption = "Error";
taskDialog.InstructionText = "Test error message.";
taskDialog.Text = "Icon seems to be missing.";
taskDialog.DetailsExpandedText = "Test";
taskDialog.DetailsCollapsedLabel = "Expand";
taskDialog.StandardButtons = TaskDialogStandardButtons.Ok;
taskDialog.Icon = TaskDialogStandardIcon.Error;
taskDialog.Show();
Run Code Online (Sandbox Code Playgroud)

我从这里使用1.1版.任何线索,为什么他们失踪以及如何启用它们?依赖关系设置如下:

  <dependency>
    <dependentAssembly>
      <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="*"
      publicKeyToken="6595b64144ccf1df"
      language="*"
/>
    </dependentAssembly>
  </dependency>
Run Code Online (Sandbox Code Playgroud)

jac*_*obz 8

我找到了解决方法.显然它是API本身的一个错误.

taskDialog.Opened += new EventHandler(taskDialog_Opened);

...

public void taskDialog_Opened(object sender, EventArgs e)
{
    TaskDialog taskDialog = sender as TaskDialog;
    taskDialog.Icon = taskDialog.Icon;
    taskDialog.FooterIcon = taskDialog.FooterIcon;
    taskDialog.InstructionText = taskDialog.InstructionText;
}
Run Code Online (Sandbox Code Playgroud)

  • 对此的解决方案是使用 Aybe 的 [WindowsAPICodePack](https://github.com/aybe/Windows-API-Code-Pack-1.1?utm_source=recordnotfound.com) (2认同)