I’ve created an extension method to Find Sibling Activity by name
Based on example from http://msdn.microsoft.com/en-us/magazine/cc163414.aspx
public static TActivity FindSiblingActivity<TActivity>(this Activity sender,string activityName) where TActivity:Activity
{
//CodeActivity thisActivityInstance = sender as CodeActivity;sender.
Activity parent = sender.Parent;
var retActivity=parent.GetActivityByName(activityName) as TActivity;
Debug.Assert(sender.IsDynamicActivity==retActivity.IsDynamicActivity," EXPECTED BOTH BE DYNAMIC");
return retActivity;
}
Related links http://geekswithblogs.net/mnf/archive/2009/04/21/workflow-activities-should-be-referred-by-sender-object-or.aspx
http://codeidol.com/other/essential-windows-workflow-foundation/Advanced-Activity-Execution/Activity-Execution-Context/