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 來捨棄擱置的變更。
針對實作 IEditableObject 的每個 Items 物件, BeginEdit 呼叫IEditableObject.BeginEdit