Skip to main content

BarItemCollection.BeginUpdate() Method

Locks the BarItemCollection by preventing change notifications from being fired, preventing visual updates until the EndUpdate method is called.

Namespace: DevExpress.Xpf.Bars

Assembly: DevExpress.Xpf.Core.v23.1.dll

NuGet Package: DevExpress.Wpf.Core


public void BeginUpdate()


Use BeginUpdate along with the EndUpdate method to prevent superfluous change notifications from being sent while performing multiple changes on the BarItemCollection. Enclose the code that performs multiple changes on the collection with the BeginUpdate and EndUpdate methods. The result will be that the change notification will fire only once, triggered by the EndUpdate method.

The BeginUpdate and EndUpdate methods use an internal counter to implement the update functionality. The counter’s initial value is 0. The BeginUpdate method increments the counter. EndUpdate decrements the counter, and if its new value is zero, change notification is enabled. Note that each call to BeginUpdate must be paired with a call to EndUpdate. If you call BeginUpdate but forget to call EndUpdate afterwards or EndUpdate is not called because an exception occurred, change notifications will no longer be fired. To ensure that EndUpdate is always called even if an exception occurs, use the try…finally statement.

After the BeginUpdate method is called for the first time, the BarItemCollection.OnBeginUpdate event fires. After a counterpart EndUpdate method has been called and the changes made have been applied, the BarItemCollection.OnEndUpdate event fires.

See Also