3

我的图标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();

我从这里使用 1.1 版。任何线索为什么它们丢失以及如何启用它们?依赖项设置如下:

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

2 回答 2

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;
}
于 2014-03-22T11:00:12.817 回答
0

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

    taskDialog.FooterIcon = taskDialog.FooterIcon;

它导致了一个未处理的异常。

于 2016-08-05T15:57:33.123 回答