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.
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<string>
. This is fixable using a custom IValueConverter
in your binding.