1

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

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?

4

1 回答 1

1

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

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

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

但是,我建议将其声明为Collection<UserInteractionProperty>因为这样更好。

于 2011-01-30T16:57:57.213 回答