Represents a base class for View Items.
The ViewItem class implements basic functionality for items that can be contained in a Detail View. This functionality includes:
The capability to display View Items via a specified control in a UI. Basically, a Detail View’s representation in a UI is a set of controls that display View Items.
A View Item can be related to the object that the parent Detail View presents. For instance, the PropertyEditor, being the ViewItem class’ descendant, represents the properties of the object presented by the Detail View.
A View Item can be refreshed when the parent Detail View is refreshed. Refreshing is assumed to be data related.
The capability to save the current settings of the control to the Application Model, so that the next time the control is created the same settings are used.
To access the Detail View in which a View Item is contained, use the ViewItem.View property.
The eXpressApp Framework ships with the following descendants of the ViewItem class:
Displays an Action Container specified by the IModelActionContainerViewItem.ActionContainer property of the Application Model‘s corresponding ActionContainerViewItem node. Used to display Actions on a Detail View layout.
Displays a control specified by the IModelControlDetailItem.ControlTypeName property of the Application Model‘s corresponding ControlDetailItem node. So, you can specify a control (Windows Forms or ASP.NET Web Forms) that will be displayed in a UI. This View Item type is declared in the DevExpress.ExpressApp.dll assembly and is UI independent.
Displays a control bound to a property of the current View’s object. There are multiple property editor types in the eXpressApp Framework. They are intended for different data types, and therefore use different controls.
Displays an image.
Displays a label.
To implement a custom View Item, inherit from the ViewItem class. The following protected members that are not described in the documentation can be overridden:
|CreateControlCore||Called by the ViewItem.CreateControl method. You should return the control that will represent your View Item in a UI.|
|SaveModelCore||Called by the ViewItem.SaveModel method. You can override it to save the settings of a View Item and its control to the Application Model. This allows display of the View Item in the same manner as it was before it was recreated.|
|Dispose||Called by the ViewItem.Dispose method. Override it if you need to dispose custom allocated resources.|
|OnCurrentObjectChanging and OnCurrentObjectChanged||Called when the ViewItem.CurrentObject property is changed.|
|OnControlCreating and OnControlCreated||Called when a control (see ViewItem.Control) is created. Raise the ViewItem.ControlCreating and ViewItem.ControlCreated events.|
A custom View Item should be implemented in a module project and decorated with the ViewItemAttribute. In this instance, it will be loaded to the Application Model, which means that you will be able to use it in a UI. Additionally, the module should be UI-specific, because the View Item creates a UI-specific control.
To access a View Item of the View for which a Controller is activated, handle the Controller.Activated and ViewItem.ControlCreated events, as it is demonstrated in the Access Editor Settings tutorial.