Skip to main content
A newer version of this page is available. .
All docs
V20.2

Access Detail View Property Editor Settings Using a Controller

  • 2 minutes to read

This lesson explains how to access editors in a Detail View and change their settings.

In this lesson, you will implement the following scenario: the Birthday property editor displays a scrollable date picker in its drop-down window.

Note

Before you proceed, take a moment to review the following lessons:

Step-by-Step Instructions

  1. Add a View Controller called “DateEditCalendarController“ to the MySolution.Module.Blazor project. Derive the controller from the ObjectViewController<ViewType, ObjectType> as shown below:

    public partial class DateEditCalendarController : ObjectViewController<DetailView, Contact> {
        public DateEditCalendarController() {
            InitializeComponent();
        }
        // ...
    }
    
  2. Override the OnActivated method. Use the DetailViewExtensions.CustomizeViewItemControl method to access the Birthday property editor settings:

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Blazor.Editors;
    using DevExpress.ExpressApp.Blazor.Editors.Adapters;
    using MySolution.Module.BusinessObjects;
    using System;
    
    namespace MySolution.Module.Blazor.Controllers {
        public partial class DateEditCalendarController : ObjectViewController<DetailView, Contact> {
            public DateEditCalendarController() {
                InitializeComponent();
            }
            protected override void OnActivated() {
                base.OnActivated();
                View.CustomizeViewItemControl<DateTimePropertyEditor>(this, SetCalendarView, nameof(Contact.Birthday));
            }
            private void SetCalendarView(DateTimePropertyEditor propertyEditor) {
                var dateEditAdapter = (DxDateEditAdapter<DateTime?>)propertyEditor.Control;
                dateEditAdapter.ComponentModel.PickerDisplayMode = DevExpress.Blazor.DatePickerDisplayMode.ScrollPicker;
            }
        }
    }
    
  • Run the application and open the Contact Detail View. The Birthday editor shows a scrollable date picker in its drop-down window.

     blazor access editor settings change editor null text

Detailed Explanation

Access Editor Settings

The CustomizeViewItemControl<T>(DetailView, Controller, Action<T>, String[]) method provides access to the property editor.

The property editor exposes the Control property that returns the Component Adapter.

Use the Component Adapter‘s ComponentModel property to access the actual Blazor component properties.

Refer to the following topic for information on how the Blazor component is integrated in XAF: How to: Implement a Property Editor Based on a Custom Component (Blazor).

ObjectViewController

In this lesson, the NullTextEditorController derives the ObjectViewController<ViewType, ObjectType> base class. The base class has two generic parameters:

You can use this class as the base class for a custom Controller to ensure that the custom Controller is activated for a specific View type and object type.

Next Lesson

Access Grid Control Settings

See Also