Home » SQL Server

How to bind out argument of an activity with the in argument of its successive activity at execution

In workflow designer I drop one activity say 'ActivityA', this activity has one out argument of type string. Now I drop another activity say 'ActivityB' in the designer (followed by ActivityA). This 'ActivityB' has one in argument of type string. Now is there any possible way that we could bind out argument of 'AcitvityA' with the in argument of 'ActivityB', such that value of out argument of 'ActivityA' becomes the value of in argument of 'ActivityB'?

Any example regarding solution of this problem would be more helpful. Thanks in advance.


1 Answer Found


Answer 1

In WF4 activity  arguments don't connect directly from OutArgument to InArgument. You need to pass the data through a Variable.




I have a custom activity named "ATest" which inherits from Activity. From the attached activity designer I fill a dictionary with InOutArguments which are already bound.
The problem now is how to bind the arguments of the parameters dictionary to child activities when we do not know the type of the arguments.

The following code works perfect, because I know that I have an Argument of type Person.

<dcwa:ATest sap:VirtualizedContainerService.HintSize="200,22">
      <p1:InOutArgument x:TypeArguments="dcwa:Person" x:Key="XPerson">[MyPerson]</p1:InOutArgument>
using System;

using System.Collections.Generic;

using System.Linq;

using System.Activities;

using System.ComponentModel;

using System.Activities.Presentation.PropertyEditing;

namespace DataModel.Core.Workflow.Activities
	publicsealedclass ATest : Activity
		private Dictionary<string, OutArgument> parameters;

		[Editor(typeof(ArgumentDictionaryEditor), typeof(PropertyValueEditor))]
		public IDictionary<string, OutArgument> Parameters
				if (this.parameters == null)
					this.parameters = new Dictionary<string, OutArgument>();

		privatereadonly Func<Activity> implementation;
		public ATest()
			this.implementation = new Func<Activity>(this.GetImplementation);

		protectedoverride Func<Activity> Implementation
			get { returnthis.implementation; }
			set	{}
		private Activity GetImplementation()
			// the next line works
			OutArgument<Person> x = Parameters.First().Value as OutArgument<Person>;

			returnnew AddPerson
				Person = new InOutArgument<Person>(c => x.Get(c))

But what should I do if I need to pass the arguments to the ReceiveParametersContent of a Receive activity.

Dictionary<string, OutArgument> dict = new Dictionary<string, OutArgument>();

foreach (KeyValuePair<string, InOutArgument> kp in Parameters)
 OutArgument argument = OutArgument.Create(kp.Value.ArgumentType, kp.Value.Direction) as OutArgument;

 // here I do not know the type for the argument, so I cannot get the context//OutArgument<string> arg = new OutArgument<string>(c => kp.Value.Get(c));
 dict.Add(kp.Key, argument);

new Receive
   DisplayName = "WaitForUserInput",
   OperationName = "MyOp",
   Content = ReceiveParametersContent.Create(dict)

Only if I specify the the type OutArgument<type>, I have access to the context.


I have flowchart as implementation  of activitybuilder and added two dynamicactivityproperty to it. The flowchart is having flowdecision and 3 other customized activities with same defined arguments. But when i invoke the workflow and pass dictionary, it gives the error:

The values provided for the root activity's arguments did not satisfy the root activity's requirements:
'Sample Workflow': The following keys from the input dictionary do not map to arguments and must be removed: FolderName, FolderSize.  Please note that argument names are case sensitive.
Parameter name: rootArgumentValues





fc = newFlowchart(); 

protectedoverridevoid OnInitialized(EventArgs e)

{ wd.Load(newActivityBuilder { Implementation =  fc});

            ModelTreeManager mtm = wd.Context.Services.GetService<ModelTreeManager>();

            ModelItem ab = mtm.Root;

            ModelItemCollection argsAndProperties = ab.Properties["Properties"].Collection;        

            InArgument<string> foldername = newInArgument<string>();

            InArgument<double> foldersize = newInArgument<double>();










{Name = "FolderName",

Type =





Value = foldername






Type =




Name =




Value = foldersize



My invoke method: 

Dictionary<string, object> Para = newDictionary<string, object>();



"FolderName", "Workflow");



"FolderSize", 100);




WorkflowInvoker.Invoke(fc, Para);

This error gets removed if I add [RequiredArgument][DefaultValue(null)] to FolderName and FolderSize(default value =0) but new error comes :

Value for a required activity argument 'FolderName' was not supplied.

Value for a required activity argument 'FolderSize' was not supplied.

 Guide me through my mistake.

Thanks in advance.







I am new to WF. I build a custom activity that need to use an external object from the host that invoke the activity. I was able to do it on a stand alone project using the activity argument for example activity that has argument1 as a string and uses writeline activity to print it.

<Activity mc:Ignorable="sap" x:Class="WorkflowConsoleApplication5.Activity1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:s4="clr-namespace:System;assembly=System.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Property Name="argument1" Type="InArgument(x:String)" />
 <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
 <Flowchart sad:XamlDebuggerXmlReader.FileName="c:\users\avik\documents\visual studio 2010\Projects\WorkflowConsoleApplication5\WorkflowConsoleApplication5\Activity1.xaml" sap:VirtualizedContainerService.HintSize="614,636">
   <scg3:Dictionary x:TypeArguments="x:String, x:Object">
    <x:Boolean x:Key="IsExpanded">False</x:Boolean>
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
    <av:Size x:Key="ShapeSize">60,75</av:Size>
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 300,169.5</av:PointCollection>
   <FlowStep x:Name="__ReferenceID0">
     <scg3:Dictionary x:TypeArguments="x:String, x:Object">
      <av:Point x:Key="ShapeLocation">194.5,169.5</av:Point>
      <av:Size x:Key="ShapeSize">211,61</av:Size>
    <WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="[argument1]" />

when I run it from the stand alone process I used

  class Program
    static void Main(string[] args)

      Activity1 a1 = new Activity1() ;
      a1.argument1 = "blah blah blah";


then I tried to run it has a xaml using  ActivityXamlServices.Load

while the activity is loaded fine I couldn't find a way to access the activity argument collection and set the value of argument1

My questions is

Is it possiable to access the argument collection of a dynamicactivity? Is there another way to accomplish the same result, meaning passing argument to a workflow prior to the invoke at run time






I am wanting to execute any workflow dynamically. However when setting up the workflow schedule I need to be able to work out if there

are any arguments which the workflow activity is expecting. How via code and not within the designer can I work out what arguments the

activity is expecting?




I am currently using several activities within Team Foundation Build that leverage the MSBuild activity.  I have set up arguments within my Build Process Templates which accepts parameters which can subsequently be passed to MSBuild.  However, the issue that I am encountering is that arguments with spaces are not reliably being surrounded by double quotes whenever necessary.  This makes it very difficult when typing arguments through the Edit Build Definition since arguments always have to be evaluated to determine whether they require surrounding double quotes or not.

Is there a way either in Team Foundation Build or through MSBuild to ensure that all arguments that contain spaces (and therefore require surrounding double quotes) are automatically escaped so that the MSBuild activities succeed?  There used to be an Exec task in NAnt which supported an args parameter that always reliably did the escaping for me.  I was hoping there would be something similar in existence for Team Foundation Build or MSBuild.




I have a (maybe) unique requirement for a workflow project which is that in some cases the workflow should be "manually" redirected to earlier executed tasks.

For example, a workflow contains Activities A, B, C and D, the workflow is currently waiting to get data to execute Activity D but something came up which requires a manual intervention to redirect the workflow back to activity B for example.

I thought that the Bookmarks would help but even with the MultipleResume option I am seemingly not able to redirect back to a previous activity.

Just for clarification, each activity candidate for receiving the focus is some sort of "waiting for input" activity like a receive or bookmark or...

So the question is, is it possible to somehow go back in the flow and what would be the best solution? Bookmark, Receive or is there another option?

Suggestions are greatly appreciated.


I have created a custom activity (referred to as X) which accesses a workflow extension and sets a property of the extension (then create a bookmark). I use this extension to get values out of the workflow as it progresses. The workflow consists of multiple child activities (all of type X).

My problem is that I persist the workflow and then, later re-load into my WorkflowApplication. It does not execute the Execute method of the current activity. Therefore, the property is not set on the extension. Thus, I am un-able to get the value from the current activity.

Hope my explanation is clear enough. Are there idea's out there to get around my problem?



If we see the execution plan of a query in Activity Monitor > Recent Expensive Queries is it Estimated Execution Plan or Actual Execution Plan ?



Binding an ExpressionTextbox to an argument is simple.

What happens when my custom activity designer contain other WPF controls like listbox, checkbox etc. How do I bind these simple controls to an argument expression. What converter should be used?





I have a window with text block. The content of the text block comes from binding, like this:
<TextBlock Text="{Binding Path=StatusText}"/>
I have a method called SetStatus, which changes value of property StatusText, binded to this text block. (The StatusText property is defined in a class, which implements INotifyPropertyChanged and OnPropertyChange is called once property has changed.)
The window hosts a user control with a button, among other things. The button click is handled with command (rather then with click event):
<Button Command="{Binding Path=DownloadCommand}"/>
My DownloadCommand is an instance of class, which implements ICommand and executes associated functionality by executing passed Action.
        readonly Action<object> _execute;
        #region Constructors
        /// <summary>
        /// Creates a new command that can always execute.
        /// </summary>
        /// <param name="execute">The execution logic.</param>
        public RelayCommand(Action<object> execute)
            _execute = execute;
        public void Execute(object parameter)
BTW, this code is taken from Josh Smith's Model-View-ViewModel sample.
Implementation of DownloadCommand's Action is as follows:
                    Cursor = Cursors.Wait
                    Cursor = Cursors.Arrow;
What I observe is, that Status is never Downloading, I can see only Finished. Also, when I push the button, it remains "pushed" about 5 seconds but cursor is changed and for 5 seconds I can see hourglass . All the above gets me to thinking, that the problem is related to binding. Looks like the fact, the button is binded to command results in that binding events (SetStatus("Downloading")) are processed after DownloadCommand is executed. In other words, there is a sequence:
execute DownloadCommand ->
                                            creates biding event to change Text in text block on Downloading , -> goes to queue
                                   requests a cursor change - done immediately
                                            creates biding event to change Text in text block on Finished, -> goes to queue
                                            requests a cursor change - done immediately
DownloadCommand is finished 
binding event change on Downloading is being processed
binding event change on Finished is being processed
How can I handle this situation and make the Status changes being processed immediately when they occur?
I've quoted excerpts from my code as original code is spread out between many classes (views and view models) and would be really hard to place them all in the post. In the real code there is a WCF operation call (interface with callback on dual channel) instead of Sleep(5000) but it behaves exactly the same.

The requirement is that the workflow should complete in a time specified as a workflow parameter, if it is not able to execute all the activities , it should terminate itself. Can anybody give me an idea how i can do that.


I'm developing DataGridTreeViewItem custom control which task is to display some icon and title. This control should be placed in TemplateColumn of wpf DataGrid.

Here is the code:

<wpfToolkit:DataGridTemplateColumnHeader="Entire Network"Width="Auto"MinWidth="200"><wpfToolkit:DataGridTemplateColumn.CellTemplate><DataTemplate><dgtvi:DataGridTreeViewItemLevel="{Binding Path=Level}"Title="{Binding Path=Title}"Lid="{Binding Path=Lid}"VerticalAlignment="Center"></dgtvi:DataGridTreeViewItem></DataTemplate></wpfToolkit:DataGridTemplateColumn.CellTemplate></wpfToolkit:DataGridTemplateColumn>

Level, Title and Lid are my own dependency properties created in DataGridTreeViewItem custom control. The control perform next logic. When Lid property has changed, it examine Title property and if Title property is empty string replace it with default value which is determined by Lid (Lid = Local ID) otherwise do nothing. The problem is that Lid property change before Title property, and we have "false" value for Title property for current DataContext obejct. I've tried to explicitly update binding by calling UpdateTarget() on appropriate BindingExpression but in some cases I've got null value for BindingExpression.

Here is the code:

BindingExpression titleExp = this.GetBindingExpression(DataGridTreeViewItem.TitleProperty);
			if (titleExp != null)

My questions are:

1. Does order of binding execution is guaranteed in WPF?

2. Generally, what is the solution for problem like this, when we have several properties which are bound to same DataContext object and their final values depends on each other ?


Let's assume I create a domain model in M and deploy it to a database, and then add values to the database via normal database access technology. Later I update the domain model, say putting all new or modified constructs in a new module name. Then I want to deploy the new module to the same database, and not alter any of the existing tables generated from the first iteration, nor the data added to those tables. I'll handle any data migration from the old module (schema) to the new module separately.

Is this scenario supported? Or is there another approach to iterating over data models that have already be deployed and are in production use?


Iremovedthesuccessivegradeshave problems.

i having a error in Delete button in GridView .



I have run into a problem.

I am trying to initialize a pure Xoml only workflow

I have some custom activities defined and a base workflow defined.


How can i bind the output of one custom activity to a variable of  the workflow or (How can i evaluate the ouput of that activity in a rule editor)?

is there a way to access dependency properties of custom activities in rule editors ??









Hi all,

I would like to know how to bind a receive activity with netMsmqBinding. Is it possible?

I mean, I want to start a Sequence (hosted in WorkflowServiceHost) by receiving a MSMQ message.




Hi all,


I would like to know if the service contract for a Receive Activity can be described by xaml and the binding as well.


Hello Everyone,

     I may just be missing something obvious here.  In 3.5 you can use dependency properties to bind two activities directly together, somewhat similar to In and OutArguments now I suppose.  I can't seem to figure out how to bind the OutArgument of one activity directly to the InArgument of another without having some kind of variable middleman between the two.  Is this not possible, or am I just missing the obvious here?

Thanks in advance,



Im trying to bind some simple CLR properties (string, int) to a custom property editor dialog. When the dialog is displayed I get the model item from the PropertyValue (using the ModelPropertyEntryToOwnerActivityConverter). I then set the DataContext of a WPF grid to the ModelItem. I have a few text controls and so on in the grid and bind them using for e.g.: <TextBox Text={Binding PropertyName, Mode=TwoWay}/> but it doesnt seem to be doing the rigtht thing as the controls dont display the current values of the properties. is this OK, should it work? Thanks for any advice.

publicvoid DataBind(ModelItem modelItem)
   this._grid.DataContext = modelItem;
<GridName="_grid"><dxl:LayoutControlOrientation="Vertical"><dxl:LayoutItemLabel="Delimiter:"><dxe:TextEditText="{Binding Path=Delimiter, Mode=TwoWay}"/></dxl:LayoutItem><dxl:LayoutItemLabel="Has Fields In Quotes:"><dxe:CheckEditIsThreeState="False"IsChecked="{Binding Path=HasFieldsEnclosedInQuotes, Mode=TwoWay}"/></dxl:LayoutItem><dxl:LayoutItemLabel="Header Rows To Skip:"><dxe:SpinEditIsFloatValue="False"Increment="1"MinValue="0"Value="{Binding Path=HeaderRowsToSkip, Mode=TwoWay}"/></dxl:LayoutItem></dxl:LayoutControl></Grid>


I have a custom activity with a read-only (only defined a getter) dependency property called "Value" and I have a dependency property "Result" on my workflow. How can I bind the value outputed by the custom activity to my workflow property?

Please help me. This is a very urgent problem in my current workflow project.

Thank you very much.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure