[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Collapse]Diagrams
    Getting Started
   [Collapse]Diagram Control
     Diagram Designer
     Canvas
     Shapes Panel
     Properties Panel
     Ribbon
     Bottom Panel
     Page Setup Dialog Window
     Print Preview
     Creating Runtime Diagram Designer
     Pan and Zoom Panel
   [Expand]End-User Interaction
   [Expand]Diagram Items
   [Expand]Automatic Layout
   [Expand]Data Binding Functionality
    Themes and Styles
    Printing and Exporting
    Saving and Loading Diagrams
   [Expand]Examples
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[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]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Properties Panel

The Properties Panel is represented by a PropertyGridControl object set as the value of the DiagramControl.PropertyGrid property. It displays properties of an object that is selected in the canvas and allows end-users to edit them.

Users can toggle the auto-hide mode or close the panel. To show the panel, right-click a diagram item or empty space in the canvas and select Properties in the menu. You can also use the Ribbon UI (View > Panes) to show or hide the Properties panel.

The table below lists the main customization options.

Characteristics Members
Availability DiagramOptionsBehavior.AllowPropertiesPanel
Display mode DiagramOptionsView.PropertiesPanelVisibility

Expanded Add Properties

To add a property to the Properties panel, handle the CustomGetEditableItemProperties (see DiagramControl.CustomGetEditableItemProperties) event. The following code snippet illustrates how to add the DiagramItem.CanSnapToThisItem property for shapes:

You can add properties from a custom DiagramItem (see DiagramItem) descendant and other sources, for example, objects stored in a DataContext.

Add a Shape Descendant's Property

To add a property from a DiagramShape (see DiagramShape) descendant, use the System.ComponentModel.TypeDescriptor.GetProperties method to obtain the PropertyDescriptor (see System.ComponentModel.PropertyDescriptor) and add it to the DiagramItemCreatingEventArgs.Properties collection:

The Properties panel uses the INotifyPropertyChanged (see System.ComponentModel.INotifyPropertyChanged) interface for notifications about updates in the source object. To enable synchronization when the Info property is modified, implement the INotifyPropertyChanged interface in the CustomDiagramShape class and raise the PropertyChanged event in the Info property setter.

Note

Use the DiagramItemTypeRegistrator.Register method to register diagram item descendants in a DiagramControl. To use custom diagram item types instead of the regular ones, handle the DiagramControl.ItemCreating event.

Add Independent Properties

The Properties panel allows users to edit properties that are not defined directly at the DiagramItem (see DiagramItem) level. This can be useful when your diagram is bound to a data source and you need to edit data item properties. For this purpose, DiagramCustomGetEditableItemPropertiesEventArgs provides the CreateProxyProperty method that allows you to create a custom property descriptor.

Add the property descriptor to the DiagramCustomGetEditableItemPropertiesEventArgs.Properties collection to edit a custom property. For instance, you can use the following code to add the Customer.Name property to the Properties panel if the DiagramShape (see DiagramShape)'s DataContext contains a Customer class instance:

Expanded Remove Properties

Tip

If you use protection options to restrict user actions, the corresponding properties are automatically removed from the Properties panel. For example, the Width and Height properties are removed from the panel if you set the DiagramOptionsProtection.AllowResizeItems property to false. The diagram protection options are listed in the DiagramOptionsProtection.IsReadOnly property's description.

To remove a property from the Properties panel, handle the DiagramControl.CustomGetEditableItemProperties and remove the corresponding property descriptor from the Properties collection:

Expanded Customize Properties

Customize Property Names

To customize a property name, handle the DiagramControl.CustomGetEditableItemProperties event. Create a custom property descriptor wrapper with the CreateProxyProperty method and use the DisplayNameAttribute attribute.

The example below illustrates how to rename the Content property.

Expanded Use Different Properties for Items of the Same Type

The DiagramControl caches property descriptors for items of the same type. Handle the CustomGetEditableItemPropertiesCacheKey (see DiagramControl.CustomGetEditableItemPropertiesCacheKey) event to conditionally choose properties for diagram items of the same type.

Expanded Validation

The PropertyGridControl supports attribute-based validation. This type of validation allows you to define validation rules for edited properties. The following code snippet adds a validation attribute that prevents users from typing a text string longer than five characters:

You can use the following attributes for validation:

Note: You should add a reference to the System.ComponentModel.DataAnnotations assembly to use these attributes.

Is this topic helpful?​​​​​​​