1

I am trying to add a custom activity designer for an activity that I have. The activity looks a little like:

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

I am trying to put a designer on the activity to make it a bit nicer to set these values (so you don't end up typing VB in directly. My designer is based on mindscape property grid. I have an ObservableDictionary source that I want to get the values from and put them in to the InArgument. Currently I am using

 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();
    }
}

However this results in an ArgumentException "Object of type UserInteractionProperty[] cannot be converted to InArgument`1[UserInteractionProperty[]].

So how do I convert my array of UserInteractionProperties into an InArgument?

skaffman
  • 398,947
  • 96
  • 818
  • 769
gbanfill
  • 2,216
  • 14
  • 21

1 Answers1

1

I am a bit late with an answer here, and I suspect that you found your bug already, because when you cam to writing the code that uses the UserInteraction you would have no where to get them from.

So the problem is that this.ModelItem.Properties["UserInteraction"] is modeling the InArgument<UserInteractionProperty[]> property and you are trying to set it with a value that is UserInteractionProperty[]. InArgument<UserInteractionProperty[]> is the type to use if you want some other workflow element to supply the list of UserInteractionPropertys. It looks like that is not the case though - I suspect that you wanted to declare your property as just a UserInteractionProperty[].

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

However I would advise declaring it as Collection<UserInteractionProperty> since that is nicer.

Neil
  • 1,605
  • 10
  • 15