Log In
[Expand]Welcome to DevExpress .NET Documentation
[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]Document Server
[Expand]Report Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
    How to: Access Navigation Control
    How to: Access the Navigation Dock Panel (in a WinForms Application)
    How to: Access the Office Navigation Bar
    How to: Access the Transition Manager
    How to: Create a New Object using the Navigation Control
    How to: Implement Custom Context Navigation
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Create a New Object using the Navigation Control

This topic demonstrates how to execute custom code on a specific navigation item click. A navigation item that invokes the Detail View in Edit mode for an Issue object is added to the Navigation control.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E236.

In this example, the following Issue persistent class is used for demo purposes. You can use any other persistent class.

To create a new object using the Navigation control, add a new navigation item and specify the code to be executed on this item click.

Expanded Add a new Navigation Item

To add a new navigation item, invoke the Model Editor for the module project by double-clicking the Model.DesignedDiffs.xafml file. Find the Issue navigation item node and add a new node to the same navigation group.

For this node, specify the properties from the table below with the corresponding values:

Refer to the Add an Item to the Navigation Control topic to learn more about creating navigation items in the Model Editor.

Expanded Specify the Code to be Executed on a Navigation Item Click

To specify the code to be executed when the Create New Issue... navigation item is clicked, follow the steps below:

  1. Create a Controller that is the WindowController descendant, override the OnActivated method, and subscribe to the ShowNavigationItemController.CustomShowNavigationItem event in this method. Use the Frame.GetController<ControllerType> method to access the ShowNavigationItemController instance.
  2. In the CustomShowNavigationItem event handler, access the current navigation item identifier using the CustomShowNavigationItemEventArgs.ActionArguments event argument.
  3. If the identifier is "NewIssue", create the following objects using the corresponding methods from the table below:
    Object Method
    Object Space XafApplication.CreateObjectSpace
    Issue object IObjectSpace.CreateObject
    Detail View for the Issue object XafApplication.CreateDetailView
  4. Set the Detail View's DetailView.ViewEditMode property to ViewEditMode.Edit and specify that this View should be displayed using the ShowViewParameters.CreatedView property.
  5. Since the Navigation control is displayed in the main Window only, the created Controller should be activated for the main Window as well by setting the WindowController.TargetWindowType property to Main in the Controller's constructor.

Run the WinForms, ASP.NET or Mobile application to check that the Issue objects can be created using the Create New Issue... navigation item (see the image at the beginning of this topic).

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