BindingGroup.BeginEdit 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
開始對來源 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的每個物件 IEditableObject ,BeginEdit呼叫IEditableObject.BeginEdit