Old System.ComponentModel
provides a DefaultValueAttribute
that, when applied to a property, marks it as having a default value in tools such as the Windows Forms Designer.
Is there an equivalent attribute in the WPF/Workflow Foundation world? The following didn't work as expected:
[DefaultValue('|')] // From System.ComponentModel
public InArgument<char> ColumnSeparator { get; set; }
The WPF Designer ignores this attribute declaration.
The equivalent is to implement IActivityTemplateFactory, and within the Create
method set all your defaults.
You can have your Activity implement this in order to keep the fuss and muss down.
public sealed class MyActivity : NativeActvity, IActivityTemplateFactory
{
public Activity Create(DependencyObject target) { /*...*/ }
// snip
Doing your configuration/initialization in this method will help you avoid all the odd corner cases you may strike when trying to initialize your Activities. You can also perform a cast on that target
and get everything you need from the state of the workflow within the design surface (e.g., automatically binding to properties).
IActivityTemplateFactory is pretty powerful. It isn't limited to just adding a single Activity. Hell, you could drop in a fully built out subassembly, so to speak, of a workflow. Its good stuff.