Windows API代码包TaskDialog缺少图标

时间:2014-03-21 14:29:39

标签: 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();

我正在使用here中的1.1版。 任何线索,为什么他们失踪以及如何启用它们?依赖关系设置如下:

  <dependency>
    <dependentAssembly>
      <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="*"
      publicKeyToken="6595b64144ccf1df"
      language="*"
/>
    </dependentAssembly>
  </dependency>

2 个答案:

答案 0 :(得分: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;
}

答案 1 :(得分:0)

我将此添加为评论,但我没有足够的代表。删除这行代码后,明确的答案对我有用:

    taskDialog.FooterIcon = taskDialog.FooterIcon;

导致未处理的异常。