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.v25.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Remarks
To use a custom View Item in the Application Model and Views, decorate your custom View Item with the ViewItemAttribute. Pass a Model interface that extends the IModelViewItem interface or its descendant as the attribute’s parameter. This interface defines the properties available in the Application Model. When the View Item is created, the corresponding model node is passed to its constructor via the model parameter:
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.