Skip to main content
.NET Framework 4.6.2+

BaseObjectSpace.ObjectChanged Event

Raised when a persistent object is created, changed or deleted.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<ObjectChangedEventArgs> ObjectChanged

Event Data

The ObjectChanged event's data class is ObjectChangedEventArgs. The following properties provide information specific to this event:

Property Description
MemberInfo Specifies an object that is information on the property whose value has been changed.
NewValue Specifies the new value of a changed property.
Object Provides access to the object that is being manipulated. Inherited from ObjectManipulatingEventArgs.
OldValue Specifies the old value of a changed property.
PropertyName Specifies the name of a property whose value has been changed. Returns null (Nothing in VB) if it is impossible to determine what property causes the change.

Remarks

This event must be raised by the BaseObjectSpace class’ descendants.

The ObjectChanged event is raised both when an object is changed directly and by means of controls. When the ObjectChanged event is raised, the object change has not yet been saved to the database.

In XPO, the ObjectChangedEventArgs.OldValue and ObjectChangedEventArgs.NewValue parameters return values only if corresponding values are passed to the SetPropertyValue or OnChanged method (otherwise, the parameters return null). In EF Core, these parameters return values only for objects that implement the INotifyPropertyChanging and INotifyPropertyChanged interfaces. These interfaces are automatically added to business objects when the UseChangeTrackingProxies option is enabled (the default configuration in new projects). For more information, see The Importance of Property Change Notifications for Automatic UI Updates. Note that the required property should be implemented as described in the The Importance of Property Change Notifications for Automatic UI Updates article and decorated with the ImmediatePostDataAttribute. The example below demonstrates how to get a new value from the EffectiveDate property.

using DevExpress.ExpressApp;
//...
public class MyExampleViewController : ObjectViewController<DetailView, DemoObject> {
    private void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) {
        if (ViewCurrentObject != null) {
            if (e.PropertyName == "EffectiveDate") {
                ViewCurrentObject.RetroDate = ViewCurrentObject.EffectiveDate;
            }
        }
    }
    protected override void OnActivated() {
        base.OnActivated();
        View.ObjectSpace.ObjectChanged += ObjectSpace_ObjectChanged;
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        View.ObjectSpace.ObjectChanged -= ObjectSpace_ObjectChanged;
    }
}

Implements

See Also