BindingGroup.BeginEdit 方法

定義

開始對來源 BindingGroup進行編輯交易。

public:
 void BeginEdit();
public void BeginEdit();
member this.BeginEdit : unit -> unit
Public Sub BeginEdit ()

範例

以下範例在視窗載入時呼叫 BeginEdit 以開始編輯交易。

void stackPanel1_Loaded(object sender, RoutedEventArgs e)
{
    // Set the DataContext to a PurchaseItem object.
    // The BindingGroup and Binding objects use this as
    // the source.
    stackPanel1.DataContext = new PurchaseItem();

    // Begin an edit transaction that enables
    // the object to accept or roll back changes.
    stackPanel1.BindingGroup.BeginEdit();
}
Private Sub stackPanel1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Set the DataContext to a PurchaseItem object.
    ' The BindingGroup and Binding objects use this as
    ' the source.
    stackPanel1.DataContext = New PurchaseItem()

    ' Begin an edit transaction that enables
    ' the object to accept or roll back changes.
    stackPanel1.BindingGroup.BeginEdit()
End Sub

備註

如果來源 BindingGroup 支援丟棄待處理的變更,你可以呼叫 BeginEdit 開始編輯交易,呼叫 CommitEdit 儲存待處理變更,呼叫 CancelEdit 刪除待處理變更。

對於實作 Items的每個物件 IEditableObjectBeginEdit呼叫IEditableObject.BeginEdit

適用於