How to get at the Activity<T> behind the Expression Text Box on a FlowSwitch<T> activity RRS feed

  • Question

  • I am programmatically adding a FlowSwitch<string> activity to a rehosted designer when a user drags a particlar node from a tree alongside the designer.
    When the model item is added to the designer, I set the Expression Text Box Value to a custom CodeActivity<string> and configure it based on the drag source.
    Based on the context of the drag source I am able to set the properties of said CodeActivity<string> so that on execution it will be able to resolve the value against which the FlowSwitch will execute.
    Thus when the FlowSwitch<string> executes, it executes my Activity<string> and the Cases the user has added are evaluated against that result. Beautiful, even though I realise it is not exactly the use case envisaged by Matt Winkler and co!
    If I look at the underlying Xaml I see the following (I have stripped out elements that are superfluous to this discussion):
     <FlowSwitch x:TypeArguments="x:String" sap:VirtualizedContainerService.HintSize="60,75">
     <deas:GetResolvedPropertyValueActivity ActivityType="Task" DisplayName="Risk" PropertyId="RFQFilterRisk" />

    Now that is all well and good but looking at the designer it is obviously not very clear to the user what the FlowSwitch is going to evaluate against.
    So necessity being the mother of invention I thought I would use the properties of my GetResolvedPropertyValueActivity as a backing store for some additional Attached Properties on the FlowSwitch<string> that I will then use to 1. modify the "Switch" label of the FlowSwitchDesigner to something a little more meaningful to the user, and 2. make the property id browsable and thus available in the property inspector view.
    I thought this would be a shoe-in using AttachedPropertiesService to add the Attached Properties and ModelService to get hold of my custom activity model item but alas no. Adding the Attached Properties is fine but the Find method of the ModelService returns null! In fact I can find no way to get at those values without parsing the xaml.
    My question is: How can I get at those properties on my GetResolvedPropertyValueActivity without having to resort to parsing the xaml?


    • Edited by Chris Wessels Friday, August 19, 2011 4:28 AM fixed typo
    Friday, August 19, 2011 4:13 AM


  • Hi Chruz,
    To me it sounds like one thing you're doing is describing a bug you have encountered in ModelService.Find.

    If so, MS will appreciate it if you have time to file it on https://connect.microsoft.com/wf with the full details. (This will actually put it on a todo list somewhere at MS, and provide a better chance of it being fixed in future .NET updates/releases.)

    In the meantime my own suggestion for working around the issue would be to traverse the model tree manually, via ModelItem.Properties, until you find the item you are looking for.

    • Proposed as answer by Tim Lovell-Smith Tuesday, November 8, 2011 11:07 PM
    • Marked as answer by Chris Wessels Thursday, November 10, 2011 10:38 PM
    Tuesday, November 1, 2011 6:59 PM