views:

295

answers:

2

I have a custom activity, with a single in argument which is a string. However, rather than allow the designer to enter an arbitrary string, I want the designer to be presented with a Combobox with the list of options, the options are dynamic and are loaded from a database into a List<> collection.

My problem is I have no clue how to bind the Combobox in the designer to this list and have the selection set to the in argument of the activity. Visually I have the activity designer working, it is just this one step.

+2  A: 

Normally I would write the activity with a property rather than an InArgument. This simplifies the scenario:

<ComboBox ItemsSource={Binding Path=ValidOptions} 
 SelectedValue={Binding Path=ModelItem.MyStringProperty, Mode=TwoWay}/>

(here ValidOptions is some Collection property on your ActivityDesigner class. MyStringProperty is some public get/set/ property on the underlying activity such as:

public string MyStringProperty { get; set; }

)

(The problem you will have if you add InArgument to the mix is that the string values from the combo box cannot be directly assigned to a ModelItem expecting InArgument. This is fixable using a custom IValueConverter in your binding.)

Tim Lovell-Smith
@Tim, sorry for taking so long to get back, it has been a hectic week and I have not even had the chance to test this to confirm that I understand and that this fits what I am trying to do. As soon as I do I will be back either to mark as answered or to probe your and the communities brain further! Thanks.
Chris Taylor
A: 

Normally I would write the activity with a property rather than an InArgument. This simplifies the scenario

I agree that it simplifies the scenario for writing the Designer, but then how do you get arguments into the Custom Activityat run-time in a workflow?

This is fixable using a custom IValueConverter in your binding

Can you please elaborate on how you would use a custom IValueConverter to solve the InArgument problem?

R T Lessly