Using Activity Properties

There are two types of activity properties: metadata properties and instance properties. A metadata property is immutable at run time. Therefore, the property must be set to a literal value at design time. An instance property can be set at design time, or the property can be bound to instance data, in which case the actual value is not determined until run time. Instance properties can also be modified directly during workflow execution.

When you implement an instance property, you can implement it like a normal .NET Framework class property, or you can implement it by using a dependency property. Only if you choose to implement it by using a dependency property can you set its value to be an ActivityBind to bind to the actual value that is accessed at run time. For more information about dependency properties, see Using Dependency Properties.

Note

If the properties are from an interface, use explicit implementation, or the compiler throws a target invocation exception. Note that when a property is explicitly implemented, it cannot be accessed through a class instance, but only through an instance of the interface.

Note

All types used in activity properties must be marked as serializable.

Property Attributes

The custom activity developer must be aware of a set of attributes when defining properties on an activity class. The Windows Workflow Foundation ValidationOptionAttribute type is used to facilitate automatic validation of metadata property values for an activity. This also means that any ValidationOptionAttribute values set for instance-based dependency properties are ignored by the DependencyObjectValidator.

The following table lists the relevant .NET Framework attributes in the System.Workflow.ComponentModel namespace.

Attribute Description

BrowsableAttribute

Specifies whether a property should be displayed in a Properties window (typically, in Visual Studio).

DefaultValueAttribute

Indicates how the property value should be interpreted. It does not mean that the property will be automatically initialized to the value specified by the attribute. For example, in your custom activity, whenever the value for the property is set to the default value, the property would not be serialized in code or markup.

DesignerSerializationVisibilityAttribute

Lets you indicate whether the value for a property is Visible and should be persisted, Hidden and should not be persisted, or consists of Content, which should have initialization code generated for each public (not hidden) property of the object assigned to the property.

EditorAttribute

When you are editing the property, a visual designer should create a new instance of the specified editor through a dialog box or drop-down window.

ParenthesizePropertyNameAttribute

Indicates to the Properties window whether the associated property name should be enclosed by parentheses. The Properties window displays a property name that is enclosed by parentheses near the top of the list in alphabetical mode, or near the top of its category if the Properties window is in categorize mode.

MergablePropertyAttribute

Properties that are marked true can be combined with properties belonging to other objects in a Properties window; properties that are marked false must be displayed separately. The default is true.

RefreshPropertiesAttribute

Indicates how a designer refreshes when the associated property value changes.

TypeConverterAttribute

Specifies what type to use as a converter for the object this attribute is bound to.

Warning

Activity properties of type Hashtable are not supported in code-separation workflows.

In This Section

Using Dependency Properties

See Also

Concepts

Creating Custom Activities
Creating Custom Activities