BindingGroup.BeginEdit 方法

定义

开始 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

适用于