.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

ViewItemAttribute Class

Applied to a custom View Item. Registers the View Item in the application and specifies the type of the Application Model's node used by the custom View Item.

Namespace: DevExpress.ExpressApp.Editors

Assembly: DevExpress.ExpressApp.v20.2.dll


[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class ViewItemAttribute :
<AttributeUsage(AttributeTargets.Class, Inherited:=True)>
Public Class ViewItemAttribute
    Inherits Attribute


When you implement a custom View Item, it should then be available in the Application Model, so that you can use it in Views. For this purpose, after you implement a custom View Item class, it should be decorated with the ViewItemAttribute. Pass a Model interface derived from the IModelViewItem interface or one of its descendants as the attribute's parameter. After this, the custom View Item will be available in the Application Model, and you will be able to use it in Views. A custom interface is required to define the properties that will be available for the implemented View Item in the Application Model. When the View Item is instantiated, the Application Model's node, corresponding to the Item, is passed via the model parameter to the View Item's constructor:

public MyDetailViewItem(IModelViewItem model, Type objectType) : base(objectType, model.Id) {

This allows you to use the data from the corresponding Application Model's node, to initialize and configure the View Item.

The ViewItemAttribute attribute has several parameters. So, you have the following options:

  • You want your View Item to be automatically set for the Application Model's nodes of a particular type. In this instance, pass the required node type as the attribute's parameter. Note that your View Item might not be used automatically as the default, if there is another View Item that uses this attribute with the same parameter.
  • You implement an extra View Item for a particular data type, but you do not want it to be automatically set for the Application Model's nodes of this type. However, you need to be able to set it manually, when required. In this instance, pass the required node type as the first attribute parameter; and false as the second attribute parameter.

To see an example of using this attribute, refer to the Implement Custom View Items help topic.


See Also