DependencyObject.SetBinding(DependencyProperty, ActivityBind) 方法


設定所指定 ActivityBindDependencyPropertySets the ActivityBind for the specified DependencyProperty.

 void SetBinding(System::Workflow::ComponentModel::DependencyProperty ^ dependencyProperty, System::Workflow::ComponentModel::ActivityBind ^ bind);
public void SetBinding (System.Workflow.ComponentModel.DependencyProperty dependencyProperty, System.Workflow.ComponentModel.ActivityBind bind);
member this.SetBinding : System.Workflow.ComponentModel.DependencyProperty * System.Workflow.ComponentModel.ActivityBind -> unit



要設定的 ActivityBindThe ActivityBind to set to.


其中一個引數是 null 參考 (Visual Basic 中為 Nothing)。Either of the arguments is a null reference (Nothing in Visual Basic).

DependencyProperty 建立關聯的 PropertyMetadata 為唯讀、是中繼資料,或是不可繫結。The PropertyMetadata associated with the DependencyProperty is read-only, is metadata, or is not bindable.

這個執行個體不在 DesignMode 中。This instance is not in DesignMode.


下列程式碼示範如何建立活動,然後將活動加入至複合活動做為子系,並且包含為這個型別設定 CanModifyActivities 權限。The following code shows how to create activities and add them as children to a composite activity and includes setting the CanModifyActivities permission for this type.

此外,說明 SetBinding 方法的使用。In addition, the use of the SetBinding method is illustrated.

這個程式碼範例是 ThrowWorkflow.cs 檔案中<擲回 SDK>範例的一部分。This code example is part of the Throw SDK sample and is from the ThrowWorkFlow.cs file. 如需詳細資訊, 請參閱使用 ThrowFor more information, see Using Throw.

this.Delay.Name = "Delay";
this.Delay.TimeoutDuration = System.TimeSpan.Parse("00:00:05");
Me.Delay.Name = "Delay"
Me.Delay.TimeoutDuration = System.TimeSpan.Parse("00:00:05")


SetValue 會直接將值設定為 DependencyPropertySetValue sets the value directly to the DependencyProperty. 同樣的,AddHandler 將處理常式直接加入型別事件的屬性。Similarly, AddHandler adds a handler directly to properties of type event.

這些方法在呼叫相同屬性時是互斥的。These methods are exclusive when they are called for the same property. 如果呼叫 SetBinding,則先前使用 SetValue (在事件中的 AddHandler) 設定的值會被忽略。If SetBinding is called, then the values previously set using SetValue (AddHandler in events) are disregarded. 反之亦相同:SetValue (AddHandler) 會重設使用 SetBinding 指派的繫結。The same is true the other way around: SetValue (AddHandler) resets the binding assigned with SetBinding.