WorkflowItemPresenter
,保存并编译时,我的活动突然消失,我没有惊慌失措的原因。我可能在某处犯了一些菜鸟错误,但我没有看到它。我已经回去并确保我的代码符合要求并删除并重新添加包含自定义活动的程序集,因为它可能只是一个侥幸。之后,当我尝试从引用我的自定义活动的项目编译时。它会运行但会抛出ArgumentNullException
。我试过传递它bool,条件和只是anthing否则它将以所有结尾相同的结果。有关故障排除想法的建议,以便在这种情况下尝试或明显的东西丢失ActivityFunc <bool> Condition
的提及。
<sap:WorkflowItemPresenter
HintText="Add Trigger conditional activities here"
Item="{Binding Path=ModelItem.Condition.Handler}"
Height="40"
/>
这是我在条件返回true public ActivityAction Child
后想要安排的孩子的参考。
<sap:WorkflowItemPresenter
HintText="Add activies that happen on trigger firing"
Item="{Binding Path=ModelItem.Child.Handler}"
Height="40"/>
这是我的自定义活动
[Designer(typeof(TriggerDesigner)),
Description("Creates a Trigger for use by trigger conditionals"), ToolboxCategory(ToolboxCategoryAttribute.Trigger),
ToolboxBitmap(typeof(Shaolin.Activities.ToolboxIconAttribute), "ToolboxIcons.CreateImportContext")]
public sealed class Trigger : NativeActivity
{
/// <summary>
/// The initial Condition that determines if the trigger should be scheduled
/// </summary>
/// <value>The condition.</value>
public ActivityFunc<bool> Condition { get; set; }
/// <summary>
/// The resulting action that is scheduled if the Condition is true
/// </summary>
/// <value>The child.</value>
public ActivityAction Child { get; set; }
/// <summary>
/// Gets or sets the value holding whether or not the trigger matches the condition
/// </summary>
/// <value>The type of the match.</value>
public MatchType MatchType{ get; set; }
/// <summary>
/// Perform evaluation of Condition; if is true then schedules Child
/// </summary>
/// <param name="context">The execution context in which the activity executes.</param>
protected override void Execute(NativeActivityContext context)
{
context.ScheduleFunc<bool>(this.Condition, new CompletionCallback<bool>(OnConditionComplete));
}
/// <summary>
/// Called from Execute when Condition evaluates to true.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="instance">The instance.</param>
/// <param name="result">if set to <c>true</c> [result].</param>
public void OnConditionComplete(NativeActivityContext context, ActivityInstance instance, bool result)
{
//check if Condition evaluation returns true
if (result)
{
//If so then schedule child Activity
context.ScheduleAction(Child);
}
}
}
}
答案 0 :(得分:2)
Hello和我一样拥有相同IP的人。
ModelItem.Condition为null。因此,你的绑定失败了,但没有大张旗鼓,这使得这种情况很难弄明白。
您需要实现IActivityTemplateFactory并在Create方法中配置您的活动:
Activity IActivityTemplateFactory.Create(System.Windows.DependencyObject target)
{
return new Trigger
{
DisplayName = "lol trigger",
Condition = new ActivityFunc<bool>(),
Child = new ActivityAction(),
MatchType = MatchType.Lol
};
}