Back to Devexpress

Supply Predefined Values for the String Property Editor Dynamically (ASP.NET Core Blazor)

expressappframework-404597-ui-construction-view-items-and-property-editors-property-editors-supply-predefined-values-for-the-string-property-editor-dynamically-supply-predefined-values-blazor.md

latest2.0 KB
Original Source

Supply Predefined Values for the String Property Editor Dynamically (ASP.NET Core Blazor)

  • Dec 18, 2025
  • 2 minutes to read

This topic describes how to implement a custom Property Editor for an ASP.NET Core Blazor application and how to dynamically populate the editor’s drop-down list with predefined values. In the scenario below, the editor is used to edit a business object’s CultureCode (locale) property of the String type. The drop-down list of the Property Editor’s control displays cultures returned by the GetCultures method.

Note

You can also use the PredefinedValues property to specify predefined values in the Model Editor. This approach is simpler as it requires no additional code, but in this case you cannot dynamically update the list of values in code.

To implement a Property Editor and supply predefined values for it, follow the steps below:

  1. Add a new CultureInfoPropertyEditor class to your ASP.NET Core Blazor Application Project. Inherit the newly created class from the BlazorPropertyEditorBase class and override the CreateComponentModel method to create a DxComboBoxModel object. This object defines the DxComboBox<TData, TValue> component.

  2. Apply the EditorAlias attribute to the required property in the business class’s definition. In this example, we use the implemented Property Editor for a business object’s CultureCode property:

  3. Build and run your application. The image below shows the resulting Property Editor: