PropertyEditorAttribute Class
Applied to a custom Property Editor. Registers the Property Editor in the application and specifies the data type for which the Property Editor is intended.
Namespace: DevExpress.ExpressApp.Editors
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
#Remarks
When you implement a custom Property Editor, it should then be available in the Application Model, so that you can use it for a property. When the application is loaded, the reflection mechanism finds all the classes decorated with the PropertyEditorAttribute attribute, and adds them to the list of available Property Editors. So, you can select your Property Editor as a value of the Views | <DetailView> | Items | <PropertyEditor> node’s IModelCommonMemberViewItem.PropertyEditorType property. In addition, you can select this Property Editor as a default editor for properties of a particular type using the ViewItems | PropertyEditors | PropertyEditor node’s IModelRegisteredPropertyEditor.EditorType property. Apply the PropertyEditorAttribute with the PropertyEditorAttribute.PropertyType parameter to the Property Editor declaration to specify that your Property Editor is designed for only a specific data type. Set PropertyType to Object to specify that your Property Editor can display properties of any type. It is possible to register a Property Editor for the class or interface which implements this type. Note, that Editor registered for the interface has a higher priority than the Editor for a type.
Note
The approach described in this topic uses the reflection mechanism, which collects information on the types decorated by the Property
This attribute has several parameters. So, you have the following options:
You want your Property Editor to be automatically set for all properties, for which another specific Editor was not applied (the DevExpress.ExpressApp.Win.Editors.DefaultPropertyEditor and DevExpress.ExpressApp.Web.Editors.ASPxDefaultPropertyEditor are used by default). In this instance, pass the Object type as the attribute’s parameter. Note that you can also set your Property Editor as default to the IModelRegisteredViewItem.DefaultItemType of the ViewItem | PropertyEditors Model Editor node.
[PropertyEditor(typeof(object), true)] public class CustomPropertyEditor : PropertyEditor { //... }
Set the defaultEditor parameter to false to add this Property Editor to the IModelRegisteredViewItem.DefaultItemType list.
You want your Property Editor to be automatically set for the properties with protected content. In this instance, implement the IProtectedContentEditor interface in your Property Editor and pass the Object type as the attribute’s parameter. Note that you can also set your Property Editor as default to the IModelRegisteredPropertyEditors.ProtectedContentPropertyEditor property of the ViewItem | PropertyEditors Model Editor node.
[PropertyEditor(typeof(object), true)] public class CustomProtectedContentPropertyEditor : PropertyEditor, IProtectedContentEditor { //... }
Set the defaultEditor parameter to false to add this Property Editor to the IModelRegisteredPropertyEditors.ProtectedContentPropertyEditor list.
You want your Property Editor to be automatically set for properties of a particular data type. In this instance, pass the required data type as the attribute’s parameter. As a result, the IModelRegisteredPropertyEditor.EditorType property is set to your Property Editor and your Property Editor is used as the default one for properties of that data type. Note that your Property Editor might not be used automatically as the default if there is another Property Editor that uses this attribute with the same parameter.
You implement an extra Property Editor for a particular data type, but you do not want it to be automatically set for properties of this data type. However, you need to be able to set it for the properties when required. In this instance, pass the required data type as the first attribute parameter; and false as the second attribute parameter. In this instance, your Property Editor is added to the IModelRegisteredPropertyEditor.EditorType list of editors available for properties of the specified data type.
Also, you can register a Property Editor with an alias using the alias parameter or the EditorAliasAttribute. This allows you to specify one alias for the ASP.NET Web Forms and WinForms Property Editors and set this alias to the DefaultItemType or EditorType property in a Model Editor with platform-agnostic settings. So, these Property Editors are applied to the corresponding platform-dependent View Item automatically and you do not need to specify these Editors individually for each platform.
To see an example of using this attribute, refer to the How to: Implement a Property Editor Based on a Custom Control (WinForms) and How to: Implement a Property Editor Based on Custom Controls (ASP.NET Web Forms) help topics.
When implementing a List Editor, use ListEditorAttribute.