The requested page is not available for the requested platform. You are viewing the content for Default platform.

BaseObjectSpace.ObjectChanged Event

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll


public event EventHandler<ObjectChangedEventArgs> ObjectChanged
Public Event ObjectChanged As EventHandler(Of ObjectChangedEventArgs)

Event Data

The ObjectChanged event handler receives an argument of the ObjectChangedEventArgs type. 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.


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.


The ObjectChanged event is raised when an end-user starts modifying any property value in a UI. In this instance, the ObjectChanged event is triggered, but the NewValue and OldValue parameters are equal. This is the designed behavior. So, if you want to execute a custom activity when a property value change occurs, initially, check the equality of these parameters.

The ObjectChangedEventArgs.OldValue and ObjectChangedEventArgs.NewValue parameters return values only for XPO persistent objects and only if corresponding values are passed to the SetPropertyValue or OnChanged method. If you use Entity Framework or non-persistent objects, the OldValue and NewValue parameters always return null (Nothing in VB). This is expected behavior, because Entity Framework doesn't provide an event that the Object Space can handle to get the modified property's old and new values. The INotifyPropertyChanged interface passes the property name only. In this scenario, you can get a new value directly from the property. Note that the required property should be implemented as described in the PropertyChanged Event in Business Classes 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() {
        View.ObjectSpace.ObjectChanged += ObjectSpace_ObjectChanged;
    protected override void OnDeactivated() {
        View.ObjectSpace.ObjectChanged -= ObjectSpace_ObjectChanged;
See Also