【问题标题】:Binding output of Custom Activity designer to activity argument将自定义活动设计器的输出绑定到活动参数
【发布时间】:2010-04-26 12:23:07
【问题描述】:

我正在尝试为我拥有的活动添加自定义活动设计器。活动看起来有点像:

public class WaitForUserInputActvitiy : NativeActivity
{
    public InArgument<UserInteractionProperty[]> UserInteraction { get; set; }
}

我正在尝试在活动中设置一个设计器,以便更好地设置这些值(因此您最终不会直接输入 VB。我的设计器基于 mindscape 属性网格。我有一个 ObservableDictionary 源我想从中获取值并将它们放入 InArgument。目前我正在使用

 private void TestGrid_LostFocus(object sender, RoutedEventArgs e)
 {
    using (ModelEditingScope editingScope = this.ModelItem.BeginEdit())
    {
        Argument myArg = Argument.Create(typeof(WaitForUserInputActvitiy), ArgumentDirection.In);
        this.ModelItem.Properties["UserInteraction"].SetValue(source.Values.ToArray());

        editingScope.Complete();
    }
}

但是,这会导致 ArgumentException“UserInteractionProperty[] 类型的对象无法转换为 InArgument`1[UserInteractionProperty[]]。

那么如何将我的 UserInteractionProperties 数组转换为 InArgument?

【问题讨论】:

    标签: wpf workflow workflow-foundation-4 custom-activity


    【解决方案1】:

    我在这里回答有点晚了,我怀疑您已经发现了您的错误,因为当您开始编写使用 UserInteraction 的代码时,您将无处可去。

    所以问题在于this.ModelItem.Properties["UserInteraction"] 正在对InArgument&lt;UserInteractionProperty[]&gt; 属性进行建模,而您正试图将其设置为UserInteractionProperty[]。如果您希望其他工作流元素提供UserInteractionPropertys 的列表,则InArgument&lt;UserInteractionProperty[]&gt; 是要使用的类型。但看起来情况并非如此 - 我怀疑您只想将您的财产声明为 UserInteractionProperty[]

    public class WaitForUserInputActvitiy : NativeActivity
    {
        public UserInteractionProperty[] UserInteraction { get; set; }
    }
    

    但是我建议将其声明为Collection&lt;UserInteractionProperty&gt;,因为这样更好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多