Can I have custom property at stateActivity level?
When you add a state (for example stateActivity1) in state workflow,
By default it has 3 properties-
stateActivity1->(name), Description and Enabled.
Is there a way to create custom property (like _userRole)?
This will help me checking the accessibility of workflow state for a certain role.
Thanks in advance.
[1013 byte] By [
sam-pan] at [2007-12-21]
Thanks for the lightning reply.
If I derive a custom stateActivity from stateActivity, will it still provide me to fill up the property like the other 3 in visual designer?
Do you have some code example?
Thanks much.
Yes it will. All you need is somethign like this:
public class MyStateActivity : StateActivity {
public static DependencyProperty MyPropertyProperty = System.Workflow.ComponentModel.DependencyProperty.Register("MyProperty", typeof(string), typeof(MyStateActivity)); [Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string MyProperty
{
get
{
return ((string)(base.GetValue(MyStateActivity.MyPropertyProperty))); }
set {
base.SetValue(MyStateActivity.MyPropertyProperty, value); }
}
}
You have to decorate the property with attributes for design time support:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[ValidationOption(ValidationOption.Optional)]
[Browsable(true)]
[Description("abcdefg.")]
[Category("Behavior")]
[Editor(typeof(YourEditor), typeof(UITypeEditor))]
public string Prop
{
get ;
set ;
}
Charles