Ticket T1280025
Visible to All Users

How to create new object in existing XAF DetailView

created 5 days ago (modified 5 days ago)

Hello,

I have a XAF ViewController that handles a specific DashboardView, containing multiple ListViews and DetailViews.
The displayed object in the DetailView should change based on which object was selected in the corresponding ListView.
When no objects are available in the corresponding ListView and thus no object is selected, I want to clear the corresponding DetailView, so I can directly create a new object within that DetailView.

I have tried many things like setting _myObjectDetailView.CurrentObject = null or _myObjectDetailView.CurrentObject = new MyObject(session), or by using _myObjectDetailView = Application.CreateDetailView(_myObjectDetailView.ObjectSpace, _myObjectDetailView.ObjectSpace.CreateObject<MyObject>()), but non of it worked, the DetailView is always grayed out.

In my EventHandler where I handle the SelectionChanged Event of the ListView, I have access to both of the corresponding ListView and DetailView:

C#
public class MyObjectsController : ViewController<DashboardView> { private ListView _myObjectListView = null!; // Set in OnActivated, so never null. private DetailView _myObjectDetailView = null!; // Set in OnActivated, so never null. private void MyObjectListViewSelectionChanged(object? sender, EventArgs e) { // Clear _myObjectDetailView here and allow the creation of a new object (MyObject) within that DetailView. } }

Answers approved by DevExpress Support

created 2 days ago

Hello,

XAF Detail View is designed to display an object, and it is not intended to be empty. To achieve your goal, consider one of the following approaches:

  • Create a new object immediately and display it in the detail view.
  • If no object exists, show another view that includes an action to create a new object.
  • Research our source code to determine if there is a way to modify the default behavior of detail views.

Let me know if any further questions arise.

Regards,
Andrey

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.