Skip to main content
.NET 6.0+

Color Properties

  • 2 minutes to read

XAF displays the Color and Nullable<Color> properties using a combo box (ASP.NET Core Blazor) or a drop-down window with a color table / color picker (Windows Forms and ASP.NET Web Forms).

Examples

ASP.NET Core Blazor

XAF’s ASP.NET Core Blazor UI implements ColorPropertyEditor to display Color properties.

XAF Color Properties ASP.NET Core Blazor, DevExpress

In ASP.NET Core Blazor, BlazorPropertyEditorBase.ComponentModel returns an IComponentModel descendant that wraps properties and events of a corresponding ASP.NET Core Blazor Editor.

The code sample below demonstrates how to apply a custom CSS class to all ColorPropertyEditor controls in the application.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;

namespace YourSolutionName.Blazor.Server.Controllers {
    public class CustomizeColorPropertiesController : ViewController {
        protected override void OnActivated() {
            base.OnActivated();
            if (View is ListView { Editor: DxGridListEditor gridListEditor }) {
                gridListEditor.CustomizeViewItemControl<ColorPropertyEditor>(this, ConfigureColorEdit);
            }
            else if (View is DetailView detailView) {
                detailView.CustomizeViewItemControl<ColorPropertyEditor>(this, ConfigureColorEdit);
            }
        }
        private void ConfigureColorEdit(ColorPropertyEditor propertyEditor) {
            propertyEditor.ComponentModel.CssClass = "myCustomCss";
        }
    }
}

Windows Forms

XAF’s Windows Forms UI implements ColorPropertyEditor to display Color properties.

XAF Color Properties WinForms

Each Windows Forms Property Editor is available in two forms:

  • A standalone control (displays property value in a Detail View)
  • A repository item (displays property value in a List Editor that supports in-place editing)

Control

Repository Item

Description

ColorEdit

RepositoryItemColorEdit

Displays Color properties. Use Alt + Down Arrow to expand the editor’s drop-down window.

ASP.NET Web Forms

XAF’s ASP.NET Web Forms UI supports two Property Editors to display Color properties (new and legacy implementations).

XAF Color Properties ASP.NET Web Forms

Each ASP.NET Web Forms Property Editor includes controls that display a property in a Detail View in View and Edit mode.

Property Editor

Description

View Mode Control

Edit Mode Control

ASPxColorPickerPropertyEditor

Allows users to select a color from a drop-down window with a color table or use the color picker to specify a custom color.

The ColorEditDisplayPanel control which wraps ColorEditDisplayControl. It displays an image with a color sample and a label with a color name. Use the ColorEditDisplayControl.ShowDisplayText property to hide the label.

ASPxColorEdit

ASPxColorPropertyEditor

Displays Color properties in legacy applications. To switch to ASPxColorPickerPropertyEditor, use the IModelRegisteredPropertyEditor.EditorType property or the ViewItems | PropertyEditors | System.Drawing.Color node in the Model Editor.

ASPxImageLabelControl from the ASP.NET Web Forms System Module. It displays an image with a color sample and a label with a color name.

ASPxComboBox