編輯

共用方式為


BindingGroup.CommitEdit Method

Definition

Runs all the ValidationRule objects and updates the binding sources if all validation rules succeed.

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

Returns

true if every ValidationRule succeeds and the values are committed to the sources; otherwise, false.

Examples

The following example calls CommitEdit to save the pending changes and then calls BeginEdit to prepare the source to be re-edited.

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

Remarks

If every ValidationRule succeeds, this method causes the sources to commit the pending changes and end the edit transaction, if a source object is capable of doing so.

For each object in Items that implements IEditableObject, CommitEdit calls IEditableObject.EndEdit

Applies to