locked
Programmatically removing Arguments in rehosted .NET 4 WF designer RRS feed

  • Question

  • In my rehosted WF 4 Designer application I need to create a custom dialog for managing the arguments of the workflow definition. I try to remove them with the following code:

     

    ModelItemCollection arguments = modelSvc.Root.Properties["Properties"].Collection;

    arguments.Clear();

     

    This clears the collection, but does not remove the items from the “Arguments” pane in the .NET 4 WF Designer. How can arguments be cleared programmatically?

    Friday, July 9, 2010 10:10 PM

Answers

  • Thanks for letting us know this issue. Unfortunately there's no easy workaround for it. Could you please try if the following works for you?

    • Is it possible to hide the default arguments designer on the surface, but provide your own arguments designer? If you want to automatically add/revove arguments in code, you might only need to show the arguments without letting user to modify it via arguments designer, thus writing your own designer (only support displaying) might not be very complex.
    • The argument designer will get updated when the *first time* it is opened. Is it possible that you make sure the arguments is added as you expected, before user get a chance to open the argument designer, and then only update the property from the argument designer after it’s opened?
    • Marked as answer by Andrew_Zhu Friday, July 16, 2010 5:48 AM
    Monday, July 12, 2010 2:09 AM

All replies

  • In my rehosted WF 4 Designer application I need to create a custom dialog for managing the arguments of the workflow definition.

     

    ModelItemCollection arguments = modelSvc.Root.Properties["Properties"].Collection;

     

    DynamicActivityProperty property = new DynamicActivityProperty()

    {

          Name = “myname”,

          Type = typeof(InArgument<MyType>),

          Attributes = { new RequiredArgumentAttribute() },

    };

     

    arguments.Add(property);

     

    However, this only seems to work the first time that argument(s) are added programmatically. On subsequent attempts the additions appear to be successful and can be used (for example as the “default” for a variable), but they don’t show in the Arguments pane.

     

    Is there a way to fix this issue?

    • Merged by Andrew_Zhu Wednesday, July 14, 2010 6:19 AM
    Friday, July 9, 2010 10:09 PM
  • sorry, what do you mean it clears the arguments?

    the argument designer is bound to the activitybuilder.properties. if you have clear that property, the arguments should have been removed.

    is the argumentdesigner open when you execute clear?

    would you mind paste me your code about how you do this?

    Friday, July 9, 2010 10:15 PM
  • I guess maybe it's caused by the argument designer refresh.

    could you try to keep your arguments designer close, and add 3 arguments and then open it to check?

    Friday, July 9, 2010 10:20 PM
  • Thanks for your response, the code I am using is in the first posting, what I mean is that when I inspect the collection in the debugger before and after the call to clear() it shows as populated and then empty but unfortunately this is not reflected in the rehosted WF Designer.

    Based on your advice, I also tried using : this.myActivityBuilder.Properties.Clear() - this also clears the properties collection in the debugger, but again it does not affect the arguments section in the designer. I have tried it with the arguments section open and closed and did not notice a difference between them. Please also note that the same basic approach for add/remove works OK in the case of variables (only problem is the variables pane is not properly refreshing after the change if it is already opened - close/reopen fixes it).

    Monday, July 12, 2010 12:21 AM
  • Thanks for your help, but although refreshing seems to be the issue on the variables side, the same behavior is not observed for arguments. For both open and closed arguments tab the behavior is the same - changes are not reflected. In the debugger both the ActivityBuilder.Properties and ModelService.Root.Properties["Properties"].Collection have the expected arguments, but the arguments tab does not show them. It seems like that collection is not bound as expected to the arguments grid. Is there a way to force a refresh or confirm that the WF Designer arguments grid is bound to that collection?
    Monday, July 12, 2010 12:36 AM
  • Thanks for letting us know this issue. Unfortunately there's no easy workaround for it. Could you please try if the following works for you?

    • Is it possible to hide the default arguments designer on the surface, but provide your own arguments designer? If you want to automatically add/revove arguments in code, you might only need to show the arguments without letting user to modify it via arguments designer, thus writing your own designer (only support displaying) might not be very complex.
    • The argument designer will get updated when the *first time* it is opened. Is it possible that you make sure the arguments is added as you expected, before user get a chance to open the argument designer, and then only update the property from the argument designer after it’s opened?
    • Marked as answer by Andrew_Zhu Friday, July 16, 2010 5:48 AM
    Monday, July 12, 2010 2:09 AM
  • I think this is the same issue you met when adding arguments in code. The issues is the same: arguments designer is not updated when you change the arguments collection in code.

    Unfortunately there's no easy workaround. I've replied in the other thread about some workaround that might be useful for you.

    Monday, July 12, 2010 2:13 AM