1

I am new to .NET 4 and I am looking for a way to design a custom activity that accepts a list of some type (in my example FormInput). So, each instance of this activity can hold its own private list of FormInput.

This codesnippet is from the activity designer what I have trying to, which for some reason, doesn't work. The datagrid is disabled when using my activity in a workflow.

<Grid>...
   <DataGrid AutomationProperties.AutomationId="InputElements" 
      ItemsSource="{Binding Path=ModelItem.InputElements}" CanUserAddRows="True"
      CanUserDeleteRows="True"></DataGrid>
...
</Grid>

And this is the property of the custom Activity class that should hold the list.

public ObservableCollection<FormInput> InputElements

Any help is appreciated.

Davi Fiamenghi
  • 1,237
  • 12
  • 28
Ibrahim
  • 11
  • 3

2 Answers2

1

I got it, think the problem was the binding to a non enumerable object.

Binding directly to the ModelItem property value resolved the issue

public partial class ActivityDesigner1
{
    public ObservableCollection<FormInput> MyProperty
    {
        get { return (ObservableCollection<FormInput>)ModelItem.Properties["InputElements"].ComputedValue; }
    }
}

And in designer: <DataGrid ItemsSource="{Binding Path=MyProperty}"...

You shoud be able to do it using a ValueConverter

Follow this link to solve the problem of adding the first item

Oh, don't forget to initialize your ObservableCollection

Community
  • 1
  • 1
Davi Fiamenghi
  • 1,237
  • 12
  • 28
0

Check if DataContext of DataGrid is set correctly and use code snippet for collection:

private ObservableCollection<FormInput> inputElements;

public ObservableCollection<FormInput> InputElements
{
    get
    {
        if (this.inputElements == null)
        {
            this.inputElements = new ObservableCollection<FormInput>();
        }

        return this.inputElements;
    }
}
Pavel Korsukov
  • 939
  • 11
  • 20