index > Windows Workflow Foundation > Custom Activity and DependencyProperty problem

Custom Activity and DependencyProperty problem

Hi,

I'm currently developing some activities to implement some human workflows with microsoft workflow foundation but i've got two problems with the "Dependency Properties".

1 - the [DefaultValue(maValue)] works only if my property is a enum or a bool. If my property is a string or a int, the defaultvalue display is respectively set to "" or 0.

2 - If i try to use a custom activity A, which have a output propery, inside a more complex one B, i can't retrieve the output property of activity A to get to the activity B: the property A is always set to null value. This problem doesn't occur if i try to use my activity A directly in a SequentialWorkflow.

Thx in advance for your help.

Pat.

A sample of a Property

public static DependencyProperty TimeOutProperty = DependencyProperty.Register("TimeOut", typeof(int), typeof DynamicPlusWebServiceActivity));

[Description("Please specify Proxy Time Out expiration time for a synchronous web service request to complete (in milliseconds)")]

[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]

[ValidationOptionAttribute(ValidationOption.Required)]

[BrowsableAttribute(true)]

[DefaultValue(300000)]

[Category("URL")]

public int TimeOut

{get{return ((int)(base.GetValue(DynamicPlusWebServiceActivity.TimeOutProperty)));}

set{base.SetValue(DynamicPlusWebServiceActivity.TimeOutProperty, value);}}




Patrick P.
Patrick P.
Regarding 1):
Default values do work for other types, however you're probably misunderstanding what they do. The [DefaultValue] attribute on a property declaration basically only tells the designer that there is a default value so that the Reset option is available in the popup menu in the property grid, and that it can restore the property to that value. It is your responsability to ensure that the value you initialize the property to in your activity's constructor matches the value you specified in the [DefaultValue] attribute.

Ohh, and btw, this is how it has always worked in the visual studio designers, including when creating custom designers for windows forms controls and so on.

Regarding 2):
I'm not sure I understand quite what you're asking. Have you checked that you're not running into spawned contexts as explained in this article? Mind you, you can also use activity binds to sometimes work around this issue (I have a small explanation on how to here.)



Tomas Restrepo [MVP]
Tomas Restrepo

Hi Thomas,

Thanks a lot for your answer.

First Question:

Effectively i've to use new PropertyMetadata(300000) in the register method to initialize my data.

Second one:

I'm running into spawned contexts as explained in your link and now all is right ;-)




Patrick P.
Patrick P.
Patrick,

AFAIK, setting the default value for your dependency property using the PropertyMetadata class is pretty much the same as the [DefaultValue] attribute on a regular property. I could be wrong, though, but it's the natural thing since most of what you specify through attributes on regular .net properties is handled in PropertyMetadata for dependency properties.



Tomas Restrepo [MVP]
Tomas Restrepo
Hi Thomas,

it's not exactly the same thing: If i use PropertyMetadata my value is correctly initialized whereas with [DefaultValue()] my value is set to zero and i need to use 'Reset' with right click to get the defaultvalue (in my case 300000).





Patrick P.
Patrick P.
Patrick,

After further checks, it appears you're right, and indeed the default value in the specified through the PropertyMetadata does indeed work differently than the [DefaultValue()] attribute.
However, notice that if you *only* specify the default value in the PropertyMetadata, then the Reset option in the designer doesn't work anymore, so it does look indeed like you should use both...



Tomas Restrepo [MVP]
Tomas Restrepo
reply 6

You can use google to search for other answers

 

More Articles

• Lotus workflow
• Share large data between workflow and application
• e-book about workflow foundation
• How to persist a workflow
• Calling a workflow exposed as a web service (beta 2)
• eventsink activity??
• Workflow Designer Control Example
• Could not find stored procedure 'RetrieveANonblockingInstanceStat...
• About the workflow desiger Rehosting?
• Is it possible to call a public method of a Workflow WebService f...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• What do i have to do in order to use Sql
• PageFlow CTP Release
• Getting error to start workflow runtime
• State Machine Workflow sending an event
• faultHandlerActivity.Fault is always null
• RSS failure: The RSS feed is not includi
• Integration with VS2005 IDE
• Workflow hangs after initialization with
• WWF performance
• Question for Workflow Monitor
• How to Change the Workflow Name in Lab 10?
• Customized Designer
• "WORKFLOW FAILED VALIDATION ERROR&q
• workflow and web apps
• How to get the workflow object within ac

Hot Articles

• clarification: correlation to the instance
• Installing Visual Studio extensions for
• Activity naming conventions and Activity
• remove connector
• Problem with Condition using Enum
• Comprehending contexts
• TrackData and Strings with Single Quotes
• Activity Binding
• Hands On Labs for the Vista 5472 build?
• Workflow Parameters?
• WWF Beta 2
• Persistence questions
• SqlTrackingService & User Events
• Any one with ASP.NET Example
• Having a policy call an external method

Recommend Articles

• WF Technology Directions
• VB wf designer problem with rules and wi
• Workflow Extensions RC5 not working?
• Beta 2.2
• Workflow runtime hosting questions
• Formatter used in Activity.Save
• Application Variables
• Issue Moving Lab 04 (Beta 2) to VB
• problem of cross-threading.
• Using CallExternalMethodActivity in a st
• Installed June CTP and now missing activ
• Composite Activity
• ASP.NET sample with WWF Beta 2?
• ASP.Net Designer example
• Interrupt State execution in State Machi