Reputation: 3799
I'm currently tinkering around with Workflow Foundation. I have an activity which contains the argument:
System.Activities.InArgument<double> Temperature
However, I want to get the value of this argument in my activity in order to do some validation with it (and also set properties in my activity based on this argument). I understand there is a Get method which takes an ActivityContext, so the actual value would be known at runtime. My question is, how can I get the ActivityContext, or is there a better way?
Note: I'm hosting the WorkflowDesigner in my app which I drop my activities on. So Activity1 contains a property "Temperature", and this is passed into Activity2 as an InArgument. I then validate Activity2, but so far can't get the ActivityContext. I don't need it at execution time, but at design time.
Thanks in advance.
Upvotes: 3
Views: 3119
Reputation: 1970
It sounds like you are wanting to use dependency properties like they had in WF3 to tie the output of activity1 to the input of activity2 at design time. Is that correct?
In the WF4 re-write they ripped out all of the dependency property stuff that allowed this.
Speaking specifically to getting access to the ActivityContext item at design time: I don't believe that is going to be possible. The AC object is created at the time of activity execution. It is what allows one instance of an activity to be executed multiple times (each iteration of a loop has a separate AC object associated with it because the AC object is created during runtime).
Here is a good Microsoft blog article describing the difference between WF3 and WF4 activity run-time execution. I think it might help clarify what you are wanting to do and how to approach the problem.
Upvotes: 2
Reputation: 31651
Can you pass the ActivityContext
to Activity2 as an argument?
What about using Custom Activity Designers?
Upvotes: 1