Skip to main content
.NET 6.0+

NavigationItemAttribute Class

Specifies whether a class will have a corresponding item in the navigation control.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
public class NavigationItemAttribute :
    Attribute

Remarks

An XAF application usually includes a navigation control in the main window. This control is a part of the Navigation System. The control implements the ShowNavigationItem Action, and the control’s items are that Action’s items. This Action allows users to switch between Views in the main window:

ASP.NET Core Blazor
XAF ASP.NET Core Blazor Navigation Control, DevExpress
Windows Forms
XAF Windows Forms Navigation Control, DevExpress
ASP.NET Web Forms
XAF ASP.NET Web Forms Navigation Control, DevExpress

The Navigation Action’s items are added from the Application Model‘s IModelRootNavigationItems node. This node’s items are created either manually via the Model Editor, or in code via the NavigationItem attribute applied to the required business class. The attribute’s NavigationItemAttribute.IsNavigationItem property must be set to true.

To specify the navigation item within the navigation control, specify the NavigationItemAttribute.GroupName attribute. By default, an item is added to the default item specified by the NavigationItemAttribute.DefaultGroupName property.

If the NavigationItemAttribute.IsNavigationItem property is set to false, or if this attribute is not applied, the ShowNavigationItem Action item list will not have the corresponding item.

In the example below, the NavigationItem attribute is applied to the TestContact class. As a result, the Test Contact item is added to the specified MyContacts navigation item in the navigation control (see the image above).

[NavigationItem("MyContacts")]
public class TestContact : BaseObject {
    public virtual string Name { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

When you need to apply the CreatableItemAttribute and VisibleInReportsAttribute attributes in addition to the NavigationItem attribute, it is easier to apply a single DefaultClassOptionsAttribute attribute.

Inheritance

Object
Attribute
NavigationItemAttribute
See Also