Search code examples
visual-studio-2010workflow-foundation-4designerpropertygrid

Exposing collection of arguments for activity in Property Grid


ExecuteSqlQuery activity from WF ADO.NET Activity Pack CTP 1 has a nice dialog for its Parameters property. I would like to use the same approach for my custom activity to provide user with ability to specifying any number of arguments in design mode and binding each argument to an expression. Is there a way to use this existing dialog box?

Collection Property Designer


Solution

  • DynamicActivityDialog provides this functionality:

    ModelItem modelItem = this.ModelItem.Properties["Arguments"].Dictionary;
    using (ModelEditingScope change = modelItem.BeginEdit("ArgumentsEditing"))
    {
        if (DynamicArgumentDialog.ShowDialog(this.ModelItem, modelItem, Context, this.ModelItem.View, options))
        {
            change.Complete();
        }
        else
        {
            change.Revert();
        }
    }
    

    And in the activity, you must have the initialized property:

    public Dictionary<string, Argument> Arguments {get; private set;}
    

    You can populate the Dictionary<string, Argument> before show the dialog for predefined itens.