BindingGroup.CommitEdit Método

Definição

Executa todos os ValidationRule objetos e atualiza as fontes de ligação se todas as regras de validação tiverem sucesso.

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

Devoluções

true se cada ValidationRule tiver sucesso e os valores forem comprometidos com as fontes; caso contrário, false.

Exemplos

O exemplo seguinte pede CommitEdit para guardar as alterações pendentes e depois para BeginEdit preparar a fonte para ser reeditada.

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

Observações

Se todos ValidationRule tiverem sucesso, este método faz com que as fontes comprometam as alterações pendentes e terminem a transação de edição, se um objeto fonte for capaz de o fazer.

Para cada objeto em Items que implementa IEditableObject, CommitEdit chama IEditableObject.EndEdit

Aplica-se a