locked
How to query all activity designers? RRS feed

  • Question

  • My question is about how, if possible at all, to retrieve all ActivityDesigner objects in a hosted workflow application? I have done some research in this area, and can only find how to query all activities using WorkflowInspectionServices.GetActivities(), but not the custom designers that are associated with each activity (note: not all activities have an associated custom designer).

    To put it simply, I need some kind of function that would do this:

    List<ActivityDesigner> designers = getDesigners(WorkflowDesigner wfDesigner);

    Thanks for your thoughts in advance!

    Thursday, October 14, 2010 9:38 PM

Answers

  • Do you have any constraint like wanting only the designers which are currently visible, or would be visible if you scrolled (but not drilling into breadcrumb view)? I'm not sure if its possible to get the invisible ones, I think the designers would normally be lazily created depending on which ones are scrolled into view.
    Tim

    • Proposed as answer by Leon Welicki - MSFT Friday, October 15, 2010 6:13 PM
    • Marked as answer by lakeeast Friday, October 15, 2010 9:17 PM
    • Unmarked as answer by lakeeast Friday, October 15, 2010 9:41 PM
    • Marked as answer by lakeeast Friday, October 15, 2010 9:48 PM
    Thursday, October 14, 2010 10:28 PM
  • Hi again,

    Just to dig deeper on the question of do you really need to set comboAppName.Text = AppName from the designer code.

    To me it seems like the best way to work around your issue is to make the value set in the Activity constructor, if possible, or literally during XAML deserialization. Then it would be initialized before the designer loads.

    But a scenario I can think of where that wouldn't work is the scenario where you specifically want to grab information that would only be available at design time, and use it to update the activity. In that case the best suggestion I have is to do save/restore of the isDirty flag around the problem code...

    Hope this helps,

    Tim

    • Marked as answer by lakeeast Tuesday, October 19, 2010 2:22 PM
    Monday, October 18, 2010 6:07 PM

All replies

  • Do you have any constraint like wanting only the designers which are currently visible, or would be visible if you scrolled (but not drilling into breadcrumb view)? I'm not sure if its possible to get the invisible ones, I think the designers would normally be lazily created depending on which ones are scrolled into view.
    Tim

    • Proposed as answer by Leon Welicki - MSFT Friday, October 15, 2010 6:13 PM
    • Marked as answer by lakeeast Friday, October 15, 2010 9:17 PM
    • Unmarked as answer by lakeeast Friday, October 15, 2010 9:41 PM
    • Marked as answer by lakeeast Friday, October 15, 2010 9:48 PM
    Thursday, October 14, 2010 10:28 PM
  • Thanks for your answer: I played with my code a little bit, and confirmed the lazy loading behavior. 

    Here is a related question: in my hosted application, I want to manage a "isDirty" flag if the user makes any changes to the workflow. My approach is to register ModelChanged event after the workflow is fully loaded, but I was surprised to discover that the lazy load of ActivityDesigner accidentally triggered a ModelChanged event, resulting in an incorrect "isDirty" flag for the application.

    My code looks like the following:

    class ViewModel{

    void LoadCommandExecute()

    {

    _workflowDesigner.Load(filename); //I am expecting all CustomDesigners to be fully initialized here

    _workflowDesigner.ModelChanged += new EventHandler(WorkflowDesigner_ModelChanged); 

    //Later changes to the workflow should be noticed with isDirty flag

    }

    void WorkflowDesigner_ModelChanged(..)

    {

    IsDirty = true;
    }

    }

    partial class MyDesigner

    {

           //Somehow the following function is called after I register the ModelChange event

    MyDesigner_Loaded(object sender, RoutedEventArgs e)

    {

    comboAppName.Text = AppName; //Causing IsDirty flag to be true :-(

    }
    }

    Is there any way to force all designers to be loaded during _workflowDesigner.Load()? Or is there any other way to ensure my IsDirty flag is kept "false" during the designer load process? Thanks!

    Friday, October 15, 2010 10:07 PM
  • Hi again,

    Just to dig deeper on the question of do you really need to set comboAppName.Text = AppName from the designer code.

    To me it seems like the best way to work around your issue is to make the value set in the Activity constructor, if possible, or literally during XAML deserialization. Then it would be initialized before the designer loads.

    But a scenario I can think of where that wouldn't work is the scenario where you specifically want to grab information that would only be available at design time, and use it to update the activity. In that case the best suggestion I have is to do save/restore of the isDirty flag around the problem code...

    Hope this helps,

    Tim

    • Marked as answer by lakeeast Tuesday, October 19, 2010 2:22 PM
    Monday, October 18, 2010 6:07 PM
  • Tim,

    Thanks for your suggestion: I re-factored my code so that the designer wouldn't touch ModelItems during initialization. Now the order of the designer load becomes a non-issue.

    Best regards

    lakeeast

    Tuesday, October 19, 2010 2:22 PM