views:

390

answers:

3

Let's say I have a Workflow with 2 dependency Property : Prop1, Prop2.

I'd like to create a custom activity that when I drag into the workflow, It will show Prop1 and Prop2 in the property grid in the designer.

Is this possible ?

Like the invokeWorkflow, when you select the TargetWorkflow, it populates the property grid with Parameters of the workflow, so that you can bind.

A: 

You shouldn't need to do anything, by default all public properties are displayed in the property grid.

AnthonyWJones
But those are properties of the workflow. I'd like my activity to detect and display the workflow properties in the designer so that i'll be able to bind to the workflow properties through my custom activity.
pdiddy
It sounds like you are asking how you get a Custom activity to display the dependency properties defined by the Workflow ancestor on which the Custom activity is placed. However that seems like a bizare requirement, can you explain why such a thing would be needed? I think it can be done but I'm questioning whether effort is worthwhile.
AnthonyWJones
A: 

If you define each one of your properties like this, the binding should be available:

[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public static readonly DependencyProperty CustomParamProperty
    = DependencyProperty.Register("CustomParam", typeof(int), typeof(CustomActivityClass));

public int CustomParam
{
    get { return (int)GetValue(CustomParamProperty); }
    set {SetValue(CustomParamProperty, value); }
}

Good Luck!

Alberto
+1  A: 

You could try something like this:

http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/10/29/DynamicWorkflowBindingParameters.aspx

I've been doing quite a bit of digging into dynamically creating properties during design time and I've had some success with it.

However, I haven't been able to get dynamic properties to show up in the actual property binding display. So you can create properties dynamically in the designer and set them, but you can set other properties to point to your dynamic properties.

This appears to be a limitation of the workflow designer in visual studio. I can't see a reason why the workflow engine itself can't handle this.

Chris Stavropoulos