I am using the designer rehosting samples and am trying to put the generic types into the toolbox, however I can't seem to make it work.
I've tried XAML based:
<sapt:ToolboxItemWrapper AssemblyName="{StaticResource AssemblyName}">
<sapt:ToolboxItemWrapper.ToolName>
System.Activities.Statements.ForEach
</sapt:ToolboxItemWrapper.ToolName>
</sapt:ToolboxItemWrapper>
and code based:
Type t = Type.GetType("System.Activities.Statements.Foreach, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
ToolboxIt开发者_开发问答emWrapper w = new ToolboxItemWrapper(t);
category.Add(w);
however neither of them seem to work. Any suggestions?
You are leaving out what isn't working but I assume you can't add a child activity to the ForEach in the designer.
If that is the case that is because the Body property is an ActivityAction not an Activity and it needs to be initialized. There are several ways of doing this but the easiest is to get started with the ForEachWithBodyFactory in the designer and drag that onto the design surface instead.
The following code works for me. I can drag the ForEach onto a workflow and add child items to it.
var cat = new ToolboxCategory("Standard Activities");
cat.Add(new ToolboxItemWrapper(typeof(ForEachWithBodyFactory<>)));
精彩评论