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]
# 1
You just have to provide a custom activity that derives from StateActivity and add the properties you'd like.
JonFlanders at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

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.

sam-pan at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

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);

}

}

}

JonFlanders at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

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

cverdon at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
Yes - I realize that - Category and Description are both *optional* however and I was trying to reduce the code sample size.
JonFlanders at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Superb!!!

You guys are awesome!! Making our life easy..

sam-pan at 2007-9-10 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified