共用方式為


BindingGroup.CommitEdit 方法

定義

如果所有驗證規則都成功,這個方法會執行所有的 ValidationRule 物件,並更新繫結來源。

public:
 bool CommitEdit();
public bool CommitEdit ();
member this.CommitEdit : unit -> bool
Public Function CommitEdit () As Boolean

傳回

Boolean

如果每一個 ValidationRule 都成功,而且這些值都被認可到來源,則為 true,否則為 false

範例

下列範例會呼叫 CommitEdit 以儲存暫止的變更,然後呼叫 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

備註

如果每 ValidationRule 一個都成功,這個方法會導致來源認可擱置的變更,並在來源物件能夠這麼做時結束編輯交易。

針對實作 IEditableObject 的每個 Items 物件, CommitEdit 呼叫IEditableObject.EndEdit

適用於