Export (0) Print
Expand All

DependencyObject.SetBinding Method

Sets the ActivityBind for the specified DependencyProperty.

Namespace: System.Workflow.ComponentModel
Assembly: System.Workflow.ComponentModel (in system.workflow.componentmodel.dll)

public void SetBinding (
	DependencyProperty dependencyProperty,
	ActivityBind bind
)
public void SetBinding (
	DependencyProperty dependencyProperty, 
	ActivityBind bind
)
public function SetBinding (
	dependencyProperty : DependencyProperty, 
	bind : ActivityBind
)
Not applicable.

Parameters

dependencyProperty

The DependencyProperty.

bind

The ActivityBind to set to.

Exception typeCondition

ArgumentNullException

Either of the arguments is a null reference (Nothing in Visual Basic).

ArgumentException

The PropertyMetadata associated with the DependencyProperty is read-only.

ArgumentException

The PropertyMetadata associated with the DependencyProperty is metadata.

ArgumentException

The PropertyMetadata associated with the DependencyProperty is not bind able.

InvalidOperationException

This instance is not in DesignMode.

SetValue sets value directly to the DependencyProperty. Similarly, AddHandler adds a handler directly to properties of type event.

These methods are exclusive when they are called for the same property. If SetBinding is called, then the values previously set using SetValue (AddHandler in events) are disregarded. The same is true the other way around: SetValue (AddHandler) resets the binding assigned with SetBinding.

The following code shows how to create activities and add them as children to a composite activity and includes setting the CanModifyActivities permissive for this type.

In addition, the use of the SetBinding method is illustrated.

This code example is part of the Throw SDK sample and is from the ThrowWorkFlow.cs file. For more information, see Using Throw.

this.CanModifyActivities = true;
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
this.throwActivity1 = new System.Workflow.ComponentModel.ThrowActivity();
activitybind1.Name = "ThrowWorkflow";
activitybind1.Path = "ThrownException";
// 
// throwActivity1
// 
this.throwActivity1.Name = "throwActivity1";
this.throwActivity1.SetBinding(System.Workflow.ComponentModel.ThrowActivity.FaultProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
// 
// ThrowWorkflow
// 
this.Activities.Add(this.throwActivity1);
this.Name = "ThrowWorkflow";
this.CanModifyActivities = false;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft