Example E236
Visible to All Users

XAF - How to Show a New Object Detail View via the Navigation Control

This example demonstrates how to execute custom code when the navigation control's item is clicked. Here we created a new object and show its detail view when a user clicks a custom item in the navigation control.

image

Implementation Details

Refer to the following topic for more information: How to: Create a New Object using the Navigation Control.

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

EF/NavigationItemEF/NavigationItemEF.Module/Controllers/NewObjectFromNavigationController.cs
C#
using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static System.Net.Mime.MediaTypeNames; using NavigationItemEF.Module.BusinessObjects; namespace NavigationItem.Module.Controllers { public class NewObjectFromNavigationController : WindowController { public NewObjectFromNavigationController() { TargetWindowType = WindowType.Main; } protected override void OnActivated() { base.OnActivated(); ShowNavigationItemController showNavigationItemController = Frame.GetController<ShowNavigationItemController>(); showNavigationItemController.CustomShowNavigationItem += showNavigationItemController_CustomShowNavigationItem; } void showNavigationItemController_CustomShowNavigationItem(object sender, CustomShowNavigationItemEventArgs e) { if (e.ActionArguments.SelectedChoiceActionItem.Id == "NewIssue") { IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Issue)); Issue newIssue = objectSpace.CreateObject<Issue>(); DetailView detailView = Application.CreateDetailView(objectSpace, newIssue); e.ActionArguments.ShowViewParameters.CreatedView = detailView; e.Handled = true; } } } }

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.