[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Collapse]Business Model Design
   [Expand]Common Tasks
   [Expand]Entity Framework (EF)
   [Expand]eXpress Persistent Objects (XPO)
   [Collapse]Non-Persistent Objects
     How to: Display a List of Non-Persistent Objects in a Popup Dialog
     How to: Display a Non-Persistent Object's Detail View from the Navigation
     How to: Display a Non-Persistent Object's List View from the Navigation
     How to: Display Non-Persistent Objects in a Report
     How to: Perform CRUD Operations with Non-Persistent Objects
     How to: Show Persistent Objects in a Non-Persistent Object's View
  [Expand]Application Model
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
  [Expand]Maps Module
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Display a Non-Persistent Object's Detail View from the Navigation

This example demonstrates how to display a non-persistent object's Detail View from the Navigation, or as a Dashboard item.


If you wish to show a non-persistent object in a modal dialog window (e.g., your task is to ask a user to fill a form), then implement a PopupWindowShowAction Action, handle its PopupWindowShowAction.CustomizePopupWindowParams event and assign the required Detail View to the handler's CustomizePopupWindowParamsEventArgs.View parameter. You can also use the ActionAttribute to show a non-persistent object by clicking an Action (see the Create an Action that Displays the Pop-up Dialog section of the How to: Create an Action Using the Action Attribute topic).

Expanded Show a Predefined Non-Persistent Object Instance

  • Declare a non-persistent class decorated with the DomainComponentAttribute. Add an object key property decorated with the KeyAttribute.


    The INotifyPropertyChanged, IXafEntityObject and IObjectSpaceLink interface implementations were omitted in this example. However, it is recommended to support these interfaces in real-world applications (see PropertyChanged Event in Business Classes and Non-Persistent Objects).

  • Rebuild the solution.
  • Run the Model Editor for the module project and add an item to the navigation. Note that only the Default navigation group content is visible in Mobile applications. Set the IModelNavigationItem.View to the identifier of the DetailView to be displayed (e.g., NonPersistentObject_DetailView). Set the IModelNavigationItem.ObjectKey to an arbitrary integer value (this value should be unique if you are going to display several different non-persistent objects of this type).


    Similarly, you can create a dashboard item instead of the navigation item.

  • Open the WinApplication.cs (WinApplication.vb), WebApplication.cs (WebApplication.vb) and/or MobileApplication.cs (MobileApplication.vb) code. Ensure that the NonPersistentObjectSpaceProvider is registered in the overridden CreateDefaultObjectSpaceProvider method (in addition to the existing XPObjectSpaceProvider or EFObjectSpaceProvider). Currently, this code is added automatically by the Solution Wizard, but it may be missing if you have created your project using an older version of XAF.

  • Create a WindowController descendant and handle the NonPersistentObjectSpace.ObjectByKeyGetting event to get an instance of the object by a key specified in the previous step.

Expanded Show a New Non-Persistent Object

If you want to create a non-persistent object automatically for each Detail View, you do not need to specify an ObjectKey in the Model Editor. Leave the ObjectKey value empty and create the following View Controller, which will create a non-persistent object automatically.

The object will be instantiated using its default constructor. You can also pass arguments to the CreateInstance method to use another constructor.

Expanded See Also

Is this topic helpful?​​​​​​​