expressappframework-devexpress-dot-expressapp-dot-xafapplication-b61afcaa.md
Occurs after an Object Space has been created via the XafApplication.CreateObjectSpace method.
Namespace : DevExpress.ExpressApp
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
public event EventHandler<ObjectSpaceCreatedEventArgs> ObjectSpaceCreated
Public Event ObjectSpaceCreated As EventHandler(Of ObjectSpaceCreatedEventArgs)
The ObjectSpaceCreated event's data class is ObjectSpaceCreatedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ObjectSpace | Gets the Object Space. |
Note
This is a legacy event. In new applications, we recommend that you use the ObjectSpaceProviderEvents.OnObjectSpaceCreated event for most use case scenarios. Refer to the Usage Considerations section for details.
If you need to access the Object Space created for a particular View, handle the ObjectSpaceCreated event and use its ObjectSpaceCreatedEventArgs.ObjectSpace parameter.
Note that nested Object Spaces are created by the XPObjectSpace.CreateNestedObjectSpace method. So, the ObjectSpaceCreated event is not raised when a nested Object Space is created.
The XafApplication.ObjectSpaceCreated event fires only for Object Spaces that are created by an XAF Application and within the XAF Application context (for example, in an XAF Controller).
Keep in mind that XafApplication does not host the Object Space creation logic and instead uses the IObjectSpaceFactory service to create Object Spaces. Other services can also directly use IObjectSpaceFactory to create Object Spaces without communicating with XafApplication. In such cases, the ObjectSpaceProviderEvents.OnObjectSpaceCreated event fires when an Object Space is created, but the XafApplication.ObjectSpaceCreated event does not.
Adhere to the following recommendations to choose the correct event to use:
IObjectSpace within the application, use ObjectSpaceProviderEvents.OnObjectSpaceCreated.XafApplication.ObjectSpaceCreated for convenience.The following code snippets (auto-collected from DevExpress Examples) contain references to the ObjectSpaceCreated event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
this.AdapterCreators = new List<Action<NonPersistentObjectSpace>>();
application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
NonPersistentObjectSpace.UseKeyComparisonToDetermineIdentity = true;
XAF_Non-Persistent-Objects-Filtering-Demo/CS/EFCore/NonPersistentFilteringEF.Module/Module.cs#L34
private void Application_SetupComplete(object sender, EventArgs e) {
Application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
}
private void Application_SetupComplete(object sender, EventArgs e) {
Application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
NonPersistentObjectSpace.UseKeyComparisonToDetermineIdentity = true;
private void Application_SetupComplete(object sender, EventArgs e) {
Application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
NonPersistentObjectSpace.UseKeyComparisonToDetermineIdentity = true;
base.Setup(application);
application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
// Manage various aspects of the application UI and behavior at the module level.
Me.AdapterCreators = New List(Of Action(Of NonPersistentObjectSpace))()
AddHandler application.ObjectSpaceCreated, AddressOf Application_ObjectSpaceCreated
NonPersistentObjectSpace.UseKeyComparisonToDetermineIdentity = True
TryCast(application.Security, SecurityStrategy)?.RegisterXPOAdapterProviders(New SecurityPermissionsProviderDefault(application))
AddHandler application.ObjectSpaceCreated , AddressOf Application_ObjectSpaceCreated
End Sub
See Also