Skip to main content
.NET Framework 4.5.2+

IObjectSpace.ModifiedChanged Event

Occurs when the current Object Space’s IObjectSpace.IsModified state is changed.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

event EventHandler ModifiedChanged

Event Data

The ModifiedChanged event's data class is EventArgs.

Remarks

In the BaseObjectSpace descendant, you don’t have to raise the ModifiedChanged event. It is raised in the protected BaseObjectSpace.SetIsModified method after the BaseObjectSpace.IsModified property has changed.

Handle this event to execute custom code when the Object Space’s Modified state is changed. However, it is already handled internally to change Actions states in dependence of the IObjectSpace.IsModified property value.

The following code disables an Action when business objects in the current Object Space are changed.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using System;
// ...
public class ViewController1 : ViewController {
    SimpleAction action1;
    public ViewController1() {
        action1 = new SimpleAction(this, "Action1", DevExpress.Persistent.Base.PredefinedCategory.View);
    }
    protected override void OnActivated() {
        base.OnActivated();
        ObjectSpace.ModifiedChanged += ObjectSpace_ModifiedChanged;
        UpdateActionState();
    }
    void ObjectSpace_ModifiedChanged(object sender, EventArgs e) {
        UpdateActionState();
    }
    protected virtual void UpdateActionState() {
        action1.Enabled["ObjectSpaceIsModified"] = !ObjectSpace.IsModified;
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        ObjectSpace.ModifiedChanged -= ObjectSpace_ModifiedChanged;
    }
}
See Also