Megosztás a következőn keresztül:


Custom Activity Binding Sample

Download sample

This sample demonstrates how to bind activity properties to workflow properties, so that the activity will be initialized with the same value as the corresponding workflow property.

Setting up custom activity binding requires a workflow that exposes a property (using the standard .NET Framework property syntax), and a custom activity that exposes a DependencyProperty member. After you add the custom activity to the workflow, you can specify the binding in the activity instance's Properties page. You can access this page from the activity's icon in the designer pane of the workflow.

In the Properties pane in Visual Studio, click the ellipsis (...) button in the value field for the activity property. This button opens the Binding dialog box, which lists workflow properties in the leftmost panel.

In the sample, a custom activity is created with a String property called NameToPrint; this simple custom activity prints this value to the console when it is executed. The workflow in the sample also exposes a property called NameToPrint; this property is set from the host application in the Parameters collection that is used to create the workflow.

When the workflow executes, the NameToPrint property of the activity is bound to the workflow's NameToPrint property. This in turn is set from the console application. The activity then writes the value to the console.

Note

This sample only shows binding between workflow properties and activity properties. Activity properties can also bind to other activity properties if necessary.

To build the sample

  1. Download the sample by clicking Download Sample in this topic.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. In the SDK Command Prompt window, run the .exe file in the HostApplication\bin\debug folder (or the HostApplication\bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.

See Also

Other Resources

Using Dependency Properties
Tutorial: Create a Custom Activity
Activity Binding Samples
Windows Workflow Foundation Samples

© 2007 Microsoft Corporation. All rights reserved.