locked
How I can get the WorkflowDesigner?.I want change the TypeArgument of FlowSwitch<> dynamically using a property grid RRS feed

  • Question

  • I read this article:

    http://blogs.msdn.com/b/tilovell/archive/2011/03/28/why-can-t-i-change-the-typeargument-of-switch-lt-gt-or-flowswitch-lt-gt-using-the-property-grid.aspx

    it explains how lets you change in a FlowSwitch<> the TypeArgument dynamically via the property grid, but i don't know what EditingContext  pass to this method:

     

    public static void MakeGenericArgumentUpdatable(EditingContext context)     

    {    

        AttachedPropertiesService aps;

        AttachedProperty property;

          

        aps = context.Services.GetService<AttachedPropertiesService>();   

        property = new AttachedProperty<Type>()      

        {   

            IsBrowsable = true,  

            Name = "TypeArgument",

            Getter = GetTypeArgument,

            Setter = SetTypeArgument,

            OwnerType = typeof(FlowSwitch<>), 

        };

     

        aps.AddProperty(property);       

    }

    Best Regards

     Octavio


    Octavio Cesar
    Friday, May 20, 2011 8:43 PM

Answers

  • Hi Octavio,

    I'm sorry to say that right now there is no way you can access the WF designer in VS so you cannot get the EditingContext via it. But I think you can override the override ActivityDesigner.OnModelItemChanged(), and retrieve the ModelItem's editing context using the extension method GetEditingContext().

    However, OnModelItemChanged() will be called every time the ModelItem is changed so you need to do some check to only publish the attached property once.

     

    By the way, I'm really interested at your work about implementing a BPMN experience using WF 4 because I'm the PM owner of WF designer. Would you mind to share more detail via email?

    Thanks.

     

    Guang Yang | Guang.Yang@microsoft.com

    • Marked as answer by Andrew_Zhu Sunday, May 29, 2011 1:56 AM
    Thursday, May 26, 2011 3:35 AM

All replies

  • Hi Octavio,
    You can get the EditingContext off of the 'WorkflowDesigner' class or off of the WorkflowViewElement and ActivityDesigner classes... since the attached properties stuff in the blog happens at a global level, probably you could go with using the WorkflowDesigner.Context upon app.

    (And thanks for the feedback! I've updated the post a little, I hope it is clearer.)

    Tim
    Saturday, May 21, 2011 12:47 AM
  • Hi Tim:

    I hope you read this.I need to capture the  WorkflowDesigner that open by Visual Studio when you double click on a. xaml that belonging to the project. It is posible?.The alternative that you propose in your blog is possible to achieve product you're the one that creates the WorkflowDesigner but I need to capture  that it is opened by VS at that time.

    Best Regards

    OCtavio


    Octavio Cesar
    Monday, May 23, 2011 4:57 PM
  • What do you need the editingcontext for (or another way of asking the same question would be how soon exactly do you need it and why)?
    Do you have a specific activity designer for which you need to register things on the editing context? Or do you want to do something that is not activitydesigner-targeted, but for solving some other problem?
    Tim
    Wednesday, May 25, 2011 5:01 PM
  • Hi Tim:

    I am a student of Computer Science at the University of Havana in Cuba.I'm working on my thesis with DSL Tools and WF4, trying to create a DSL based on BPMN 2.0 generating activities in WF 4. My development environment, I mean, where my tool is hosted is in Visual Studio itself. For that reason I need the EditingContext that belongs to the WorkflowDesigner that is opened by VS when  you double click on a .xaml that belongs to the project.

    In sumary, I want to ‘Add’ a TypeArgument property in the property grid for FlowSwitch<T> in the same way that ForEach<T> does, but I need the WorkflowDesigner that is opened by VS.

    Best Regards

    Octavio


    Octavio Cesar


    Wednesday, May 25, 2011 6:12 PM
  • Hi Octavio,

    I'm sorry to say that right now there is no way you can access the WF designer in VS so you cannot get the EditingContext via it. But I think you can override the override ActivityDesigner.OnModelItemChanged(), and retrieve the ModelItem's editing context using the extension method GetEditingContext().

    However, OnModelItemChanged() will be called every time the ModelItem is changed so you need to do some check to only publish the attached property once.

     

    By the way, I'm really interested at your work about implementing a BPMN experience using WF 4 because I'm the PM owner of WF designer. Would you mind to share more detail via email?

    Thanks.

     

    Guang Yang | Guang.Yang@microsoft.com

    • Marked as answer by Andrew_Zhu Sunday, May 29, 2011 1:56 AM
    Thursday, May 26, 2011 3:35 AM