Current filter:
                                You should refresh the page.
                                  • There are several ways to assign an XAF property editor to a business class property or property type:


                                    1. Assign a property editor via the Application Model (Model Editor).

                                    1.1. Specify a default property editor for a property type globally via the IModelRegisteredPropertyEditor.EditorType property of the ViewItems / PropertyEditors / <TypeName> model node.

                                    1.2. Specify a property editor for a class property via the IModelCommonMemberViewItem.PropertyEditorType property of the BOModel / <ClassName> / OwnMembers / <PropertyName> model node. It is the default property editor used for this property in list and detail views.

                                    1.3. Specify a property editor for a detail view item via the IModelCommonMemberViewItem.PropertyEditorType property of the Views / <DetailViewName> / Items / <ItemName> model node.

                                    1.4. Specify a property editor for a list view column via the IModelCommonMemberViewItem.PropertyEditorType property of the Views / <ListViewName> / Columns / <ColumnName> model node.


                                    2. Assign a property editor declaratively (via attributes). These attributes are taken into account when the application model is being generated.

                                    2.1. Specify a default property editor when registering a property editor. When creating a custom property editor, you decorate the editor class with the PropertyEditor attribute, where you can specify the property type for which the editor can be selected and set the isDefaultEditor property to True to use it for this type by default.

                                    [C#]
                                    [PropertyEditor(typeof(String), true)] public class CustomStringEditor : StringPropertyEditor { public CustomStringEditor(Type objectType, IModelMemberViewItem info) : base(objectType, info) { } //... }
                                    [VB.NET]
                                    <PropertyEditor(GetType(String), True)> Public Class CustomStringEditor Inherits StringPropertyEditor Public Sub New(ByVal objectType As Type, ByVal info As IModelMemberViewItem) MyBase.New(objectType, info) End Sub '... End Class


                                    2.2. Specify a property editor type by applying the DevExpress.ExpressApp.Model.ModelDefault attribute to a property and refer to the model property mentioned in (1.2). For example, [ModelDefault("PropertyEditorType", "<FullEditorTypeName>")]. This approach is only useful for platform-agnostic property editors or classes declared in platform-specific modules, because the exact type name is used.

                                    [C#]
                                    //Class declared in a WinForms module, for example public class BusinessObject : BaseObject { //... [ModelDefault("PropertyEditorType", "SampleSolution.Module.Win.PropertyEditors.CustomStringEditor")] public string Description { get { return GetPropertyValue<string>("Description"); } set { SetPropertyValue<string>("Description", value); } } }
                                    [VB.NET]
                                    'Class declared in a WinForms module, for example Public Class BusinessObject Inherits BaseObject '... <ModelDefault("PropertyEditorType", "SampleSolution.Module.Win.PropertyEditors.CustomStringEditor")> Public Property Description() As String Get Return GetPropertyValue(Of String)("Description") End Get Set(ByVal value As String) SetPropertyValue(Of String)("Description", value) End Set End Property End Class

                                    2.3. Specify a property editor alias by applying EditorAliasAttribute to a property. This approach allows you to automatically select an appropriate platform-specific editor associated with an alias depending on the application platform. All built-in property editors have aliases declared in the DevExpress.ExpressApp.Editors.EditorAliases struct. For custom editors, an alias can be specified in the PropertyEditor attribute applied to the editor class.

                                    [C#]
                                    public class BusinessObject : BaseObject { //... [EditorAlias("CustomStringEdit")] public string Description { get { return GetPropertyValue<string>("Description"); } set { SetPropertyValue<string>("Description", value); } } } [PropertyEditor(typeof(String), "CustomStringEdit", false)] public class CustomStringEditor : StringPropertyEditor { public CustomStringEditor(Type objectType, IModelMemberViewItem info) : base(objectType, info) { } //... }
                                    [VB.NET]
                                    Public Class BusinessObject Inherits BaseObject '... <EditorAlias("CustomStringEdit")> Public Property Description() As String Get Return GetPropertyValue(Of String)("Description") End Get Set(ByVal value As String) SetPropertyValue(Of String)("Description", value) End Set End Property End Class <PropertyEditor(GetType(String), "CustomStringEdit", False)> Public Class CustomStringEditor Inherits StringPropertyEditor Public Sub New(ByVal objectType As Type, ByVal info As IModelMemberViewItem) MyBase.New(objectType, info) End Sub '... End Class

                                    2.4. Specify a property editor alias by applying EditorAliasAttribute to a class. If this attribute is applied to a business class, then the property editor associated with the specified alias will be used for all reference properties of the target type.

                                    [C#]
                                    [EditorAlias("MyObjectPropertyEditorAlias")] public class MyBusinessObject { //... }
                                    [VB.NET]
                                    <EditorAlias("MyObjectPropertyEditorAlias")> Public Class MyBusinessObject '... End Class


                                    3. Assign a property editor at runtime (programmatically).
                                    The aforementioned methods are recommended ways to register property editors in most scenarios. It is also possible to make these customizations dynamic: How to change the default Application Model value globally or for multiple nodes. If you want to speed up your application start and also control default editors for each property type, business class and its members, override the ModelBase.RegisterEditorDescriptors method.

                                    See Also:
                                    Concepts UI Construction | View Items
                                    Data Types Supported by built-in Editors 

                                0 Solutions

                                Creation Date Importance Sort by