【问题标题】:Workflow Foundation 4 in VS 2015 - Activity toolbox bitmaps don't showVS 2015 中的 Workflow Foundation 4 - 活动工具箱位图不显示
【发布时间】:2016-05-24 22:42:39
【问题描述】:

我已经阅读了多个关于此的教程/博客/stackoverflow 问题,包括以下内容:

还有更多。

它们中的大多数已经过时了。 有人建议 Activity Designer 库名称应以 Design.dll 结尾,其他人则建议它应以 VisualStudio.Design.dll 结尾。 有人说该库应该部署到 Visual Studio 的 bin 路径,也有人说它不需要。

这一切都非常混乱。

我可以使活动工具箱位图仅在使用 ToolboxBitmapAttribute 直接在activity上,并且只有当嵌入的bmp图标在activity库中时,例如:

[ToolboxBitmap(typeof(MyActivity), "Resources.Bitmaps.MyActivity.bmp"]
public class MyActivity : CodeActivity
{
}

如果我将位图移动到活动设计器库,引用活动库中的活动设计器库,并直接在活动上使用 ToolboxBitmapAttribute(使用正确的嵌入路径并使用活动设计器库中的类型) - 它确实不工作。

[ToolboxBitmap(typeof(MyActivityDesigner), "Resources.Bitmaps.MyActivity.bmp"]
public class MyActivity : CodeActivity
{
}

如果我使用 ActivityDesigner 库中的 IRegisterMetadata 接口,将 ToolboxBitmapAttribute 注册到元数据存储中的 MyActivity 类型:

AttributeTableBuilder builder = new AttributeTableBuilder();
builder.AddCustomAttributes(typeof(MyActivity), new DesignerAttribute(typeof(MyActivityDesigner)));
builder.AddCustomAttributes(typeof(MyActivity), new ToolboxBitmapAttribute(typeof(MyActivityDesigner), "Resources.Bitmaps.MyActivity.bmp"));
MetadataStore.AddAttributeTable(builder.CreateTable());

仍然没有活动的工具箱位图。

活动设计器工作正常!

看来 VS 正在加载 MyActivities.Design.dll 库,但由于某种原因忽略了 ToolboxBitmapAttribute。

我会很感激这个提示。

【问题讨论】:

  • 你有没有得到这个工作?
  • 不怕。我想我已经选择了工作选项。
  • 我花了一些时间试图弄清楚(3 小时以上)。唯一可行的方法是您提到的属性

标签: bitmap visual-studio-2015 workflow-foundation-4 workflow-foundation toolbox


【解决方案1】:

您可能想试试 ActivityDesigner 的 Icon 属性。确保图像在活动设计者的项目中并标记为构建操作上的资源:

<sap:ActivityDesigner.Icon>
    <DrawingBrush>
        <DrawingBrush.Drawing>
            <ImageDrawing>
                <ImageDrawing.Rect>
                    <Rect Location="0,0" Size="25,25" ></Rect>
                </ImageDrawing.Rect>
                <ImageDrawing.ImageSource>
                    <BitmapImage UriSource="MyActivityIcon.png" />
                </ImageDrawing.ImageSource>
            </ImageDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>
</sap:ActivityDesigner.Icon>

【讨论】:

  • 感谢您的回答乔塔。不幸的是,这不是问题。正如我在帖子中所说,ActivityDesigner 本身可以完美地工作,包括图标等等。问题在于工具箱位图(VisualStudio 工具箱面板中活动的 16X16 小图像)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多