学习008-02-04-06 Access the Settings of a Property Editor in a Detail View(在详细信息视图中访问属性编辑器的设置)

Access the Settings of a Property Editor in a Detail View(在详细信息视图中访问属性编辑器的设置)

This lesson explains how to access editors in a Detail View and change their settings.
本课介绍如何访问详细信息视图中的编辑器并更改其设置。

The instructions below show how to make the Birthday property editor display a scrollable date picker in its drop-down window.
下面的说明展示了如何使Birthday属性编辑器在其下拉窗口中显示可滚动的日期选择器。

Note
Before you proceed, take a moment to review the previous lessons:
在继续之前,请花点时间回顾一下之前的课程:

  • Implement a Data Model: Basics
  • Add a Simple Action

Step-by-Step Instructions(分步说明)

1.In the MySolution.Blazor.Server and MySolution.Win projects, add a View Controller to the Controllers folder. Name the new controller DateEditCalendarController. Specify the controller ancestor class ObjectViewController<ViewType, ObjectType>:
在MySolutions. Blazor.Server和MySolution.Win项目中,将View Controller添加到Controller文件夹。将新控制器命名为DateEditCalendarController。指定控制器祖先类ObjectViewController<ViewType,ObjectType>:

ASP.NET Core Blazor
C#

using DevExpress.ExpressApp;
using MySolution.Module.BusinessObjects;
// ...
namespace MySolution.Blazor.Server.Controllers {
    public class DateEditCalendarController : ObjectViewController<DetailView, Employee> {
    // ...
    }
}

Windows Forms
C#

using MySolution.Module.BusinessObjects;


namespace MySolution.Win.Controllers {
    public class DateEditCalendarController : ObjectViewController<DetailView, Employee> {
        public DateEditCalendarController() {
            //...
        }
        // ...
    }
}

The DateEditCalendarController inherits from the ObjectViewController<ViewType, ObjectType> base class. The parameters of the base class enable the Controller only for Detail Views that display and edit Employee objects.
DateEditCalendarController继承自ObjectViewController<ViewType, ObjectType>基类。基类的参数仅为显示和编辑员工对象的详细信息视图启用控制器。

2.Override the OnActivated method. Use the DetailViewExtensions.CustomizeViewItemControl method to access the Birthday property editor settings:
覆盖OnActivated方法。使用DetailViewExtensions.CustomizeViewItemControl方法访问Birthday属性编辑器设置:

ASP.NET Core Blazor
C#

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

namespace MySolution.Blazor.Server.Controllers {
    public partial class DateEditCalendarController : ObjectViewController<DetailView, Employee> {
        protected override void OnActivated() {
            base.OnActivated();
            //Access the Birthday property editor settings
            View.CustomizeViewItemControl<DateTimePropertyEditor>(this, SetCalendarView, nameof(Employee.Birthday));
        }


        private void SetCalendarView(DateTimePropertyEditor propertyEditor) {
            //Set the date picker display mode to scroll picker
            propertyEditor.ComponentModel.PickerDisplayMode = DevExpress.Blazor.DatePickerDisplayMode.ScrollPicker;
        }
    }
}

Windows Forms
C#

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.XtraEditors;
using MySolution.Module.BusinessObjects;


namespace MySolution.Win.Controllers {
    //...
    public class DateEditCalendarController : ObjectViewController<DetailView, Employee> {
        public DateEditCalendarController() {
             // ...
        }
        protected override void OnActivated() {
            base.OnActivated();
            //Access the Birthday property editor settings
            View.CustomizeViewItemControl(this, SetCalendarView, nameof(Employee.Birthday));
        }
        private void SetCalendarView(ViewItem viewItem)
        {
            //Set the currently displayed View Item control to a drop-down calendar
            DateEdit dateEdit = (DateEdit)viewItem.Control;
            //Set the appearance of the calendar in the drop-down window
            dateEdit.Properties.CalendarView = DevExpress.XtraEditors.Repository.CalendarView.TouchUI;
        }
     //...
    }
}

3.Run the application and open the Employee Detail View. The Birthday editor shows a scrollable date picker in its drop-down window:
运行应用程序并打开员工详细信息视图。生日编辑器在其下拉窗口中显示了一个可滚动的日期选择器:

ASP.NET Core Blazor
在这里插入图片描述

Windows Forms
在这里插入图片描述

Tip
For general information on Property Editor architecture and UI Controls used by XAF, review the following articles:
有关XAF使用的属性编辑器体系结构和UI控件的一般信息,请查看以下文章:

  • Implement a Property Editor Based on a Custom Component (Blazor)(实现基于自定义组件(Blazor)的属性编辑器)
  • Implement a Property Editor Based on a Custom Control (WinForms)(实现基于自定义控件(WinForms)的属性编辑器)
  • Data Types Supported by built-in Editors(内置编辑器支持的数据类型)

Next Lesson(下一课)

Format a Property Value
格式化属性值

  • 17
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

thomastang200912_126

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值