views:

6

answers:

1

I have an activity that has properties that look something like this (they're set up as proper dependency properties, I just kept it simple here):

public List<MyType> TypeList { get; set; }
public Int32 Index { get; set; }
public MyType SelectedType { get; set; }

and an execution that just does this:

SelectedType = TypeList[Index];

TypeList and Index are values that I set from other activities. I don't set SelectedType to anything in the activity properties, I just let it get set in the execution.

Now I know for a fact that SelectedType is getting set properly, I can even point another activity to it and print out some values from it. So I'm quite positive that there's nothing wrong with that activity.

However, I have an if activity with a condition that looks like this:

((MyActivity)GetActivityByName("activity1")).SelectedType != null

and it evaluates to false (meaning it evaluated SelectedType as null). I'm pretty sure that that activity cast is correct (I do things like that all the time), and if it weren't wouldn't I get a null reference exception when trying to access SelectedType? So I'm pretty sure I'm not doing anything wrong here, but for some reason SelectedType is coming up null in that condition and no where else.

It's almost as if the condition is being evaluated before the activity is being run, but the activity comes well before the condition in the workflow, so I don't see why that would be the case.

Can anyone shed some light on this?

A: 

Apparently it has to do with the while loop causing activities to be cloned. I fixed it by binding the activity property to workflow properties. For more info, see this post that I put up on the workflow forums.

Mike Pateras