Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]Actions
  [Expand]Navigation
  [Collapse]Views
    How to: Access Objects Selected in the Current View
    How to: Access the Master Object from a Nested List View
    How to: Create and Show a Detail View of the Selected Object in a Popup Window
    How to: Detect a Lookup List View in Code
    How to: Display a Detail View Directly in Edit Mode in ASP.NET and Mobile Applications
    How to: Display a List View as a Chart
    How to: Display Several Views Side-by-Side
    How to: Hide Collection Properties in an Edit Mode Detail View for an ASP.NET Application
    How to: Implement a Singleton Business Object and Show its Detail View
    How to: Implement a View Item
    How to: Show a Custom Data-Bound Control in an XAF View (ASP.NET)
    How to: Show a Custom Data-Bound Control in an XAF View (WinForms)
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Templates
  [Expand]Filtering
  [Expand]Reporting
  [Expand]Dashboards
  [Expand]Scheduler and Notifications
  [Expand]Maps
  [Expand]Security
  [Expand]Workflow
  [Expand]Localization
  [Expand]Testing
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Implement a View Item

This topic demonstrates a way of implementing a custom View Item, and displaying it on all Detail Views by default. This View Item will show an image representing the current business object (the same image is used within the navigation control). Since a Windows control will be used to display this View Item, this feature will be available in WinForms applications only.

 

Before proceeding, we recommend that you review the following lessons.

 

To create a custom View Item, you need to declare a ViewItem class descendant. This declaration should reside within your application's WinForms module project (see Application Solution Structure). To make a new child node appear in the ViewItems node of the Application Model, the ViewItem attribute should be applied to the ViewItem descendant. Pass a Model interface derived from the IModelViewItem interface, or one of its descendants, as the attribute's parameter. In this interface, define the properties that will be available for the implemented View Item in the Application Model. Then, the custom View Item will be available in the Application Model and you will be able to use it in Views.

The following code demonstrates how the custom View Item can be implemented. The CreateControlCore method is overridden to create a control that will represent the View Item in a UI. An image name is read from the particular Views | DetailView | ClassIcon node. The custom IModelClassIcon Model interface does not declare any additional properties.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E242.

The following picture demonstrates the ClassIcon node, representing the newly declared View Item in the Application Model.

Now you will be able to add the custom View Item to any Detail View, as you would with built-in View Items. To make this item visible in all Detail Views by default, the Application Model should be customized in code (see Extend and Customize the Application Model in Code). You should implement ModelNodesGeneratorUpdater<T> descendants (Generator Updaters) for the ModelDetailViewLayoutNodesGenerator and ModelDetailViewItemsNodesGenerator Nodes Generators. These Updaters must be registered within the overridden ModuleBase.AddGeneratorUpdaters method. The following code shows how to do this.

You can now run the application. All Detail Views will contain class icons.

How would you rate this topic?​​​​​​​