Container Activity RRS feed

  • Question

  • I'm trying to design a container Activity.
    The container Activity is verry simple here is the code:


    public class MyContainer : NativeActivity
    public InArgument<string> ArgOne { get; set; }

    public InArgument<string> ArgTwo { get; set; }

    [Browsable(false)] public Activity Body { get; set; }

    [Browsable(false)] public Collection<Variable> Variables { get; set; }

    public MyContainer()
    //collection initialisieren
    this.Variables = new Collection<Variable>();

    protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
    //caching metadata aus performance gründen

    RuntimeArgument aktArt = new RuntimeArgument("MyArgOne", typeof(string),ArgumentDirection.In);
    metadata.Bind(this.ArgOne, aktArt);

    RuntimeArgument aktBez = new RuntimeArgument("MyArgTwo", typeof(string), ArgumentDirection.In);
    metadata.Bind(this.ArgTwo, aktBez);

    if (this.Variables.Count > 0)
    foreach (var variable in this.Variables)


    protected override void Execute(System.Activities.NativeActivityContext context)


    The designer simply allows yout to drop an activity to the Body.
    If i understand it wright the Arguments are available for all ChildActivities.
    Now i'm trying to create a new Activity in VS with the Designer using for example an FlowChart and at a point im assigning the ContentActivity.
    The designer recognise the Required Arguments and show validation error.

    The problem is when i assing a WriteLine, for example, to the Body and trying to access the ArgOne argument.
    The validation say, "ArgOne" is not Assigned. Cannot access Object because of the SecurityLevel. (Translated Manuall, i am German original message: "Beim Verarbeiten des Ausdrucks"ArgOne" ist mindestens ein Compilierfehler aufgetreten. "ArgOne" ist nicht deklariert. Auf das Objekt kann aufgrund der Schutzstufe möglicherweise nicht zugegriffen werden.)

    So the problem i have is that Intellisense do not support my arguments parsed to the Body(Content) and i cannot access the Argument from my Content cause of the Validation Error.

    Friday, February 18, 2011 2:08 PM


All replies

  • Hello Roland,
    Let me start by saying that I feel your pain.  Some time back I too was hoping to provide very similiar functionality.  I remember spending a lot of hours trying to figure out a way to accomplish it from a number of approaches but never got anything to work that I was satisfied with.  What I ultimately determined was that while i thought I needed this functionality I really didn't.  I realized that any activity that I dropped into the body of my container was being defined on the same xaml activity as my container itself.  Therefore, if my body needed the value passed into my container, the value could also be passed directly into my body from its original source. 

    Of course, its never really that simple.  What I was personally after was establishing a context so that I wouldn't have to pass along an argument through layers of children.  This was important to me because the activities that would ultimately be placed in the body weren't supposed to know about my property.  For this particular problem I found my solution was ExecutionProperties that could be set and retrieved through NativeActivityContext::Properties.

    Regretfully, I never really researched further and just concluded it wasn't possible. Hopefully somebody else will chime in with a happier story.  :)


    Saturday, February 19, 2011 4:33 AM
  • Hi,

    To create a composite activity and its activity designer, please see this blog entry I wrote sometime ago:

    Hope this helps
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Friday, February 25, 2011 2:28 AM
    Tuesday, February 22, 2011 3:38 AM