Back to Devexpress

NavigationItemAttribute Class

expressappframework-devexpress-dot-persistent-dot-base-6360bbee.md

latest4.8 KB
Original Source

NavigationItemAttribute Class

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

Namespace : DevExpress.Persistent.Base

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
public class NavigationItemAttribute :
    Attribute
vb
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=False)>
Public Class NavigationItemAttribute
    Inherits 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 Windows Forms

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 following code snippet, 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).

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

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
csharp
[NavigationItem("MyContacts")]
public class TestContact : BaseObject {
   public TestContact(Session session) : base(session) {}
   private string name;
   public string Name {
      get {
         return name;
      }
      set {
         SetPropertyValue(nameof(Name), ref name, value);
      }
   }
}

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

NavigationItemAttribute Members

Data Annotation Attributes

Navigation System

DevExpress.Persistent.Base Namespace