学习008-01-03 Customize the Application UI and Behavior(自定义应用程序UI和行为)

news2024/9/24 5:33:17

Customize the Application UI and Behavior(自定义应用程序UI和行为)

In XAF, the data model defines the database structure and UI. Changes to your entity classes affect the UI. For example, if you add a new property to an entity class, a new editor appears in the corresponding List and Detail views.
在XAF中,数据模型定义了数据库结构和UI。对实体类的更改会影响UI。例如,如果向实体类添加新属性,则会在相应的List和Detail视图中显示新的编辑器。
You can use the auto-generated UI or customize it according to your business requirements and scenarios. This topic describes how to customize your application’s appearance and behavior.
您可以使用自动生成的UI或根据您的业务需求和场景对其进行自定义。本主题介绍如何自定义应用程序的外观和行为。

Customize the Application UI Metadata(自定义应用程序UI元数据)

Use Attributes in Code(在代码中使用属性)

You can use built-in attributes to edit the Application Model, create controls, and customize the application’s appearance and behavior. For example, you can validate field content, change field visibility, or format displayed data with one line of code.
您可以使用内置属性来编辑应用程序模型、创建控件以及自定义应用程序的外观和行为。例如,您可以使用一行代码验证字段内容、更改字段可见性或格式化显示的数据。
Follow the steps below to replace the Quote property’s single-line editor with a multi-line editor.
按照以下步骤将Quote属性的单行编辑器替换为多行编辑器。

1.Apply the FieldSizeAttribute attribute to the Quote property in the Testimonial class and pass Unlimited as the attribute’s parameter.
将FieldSizeAtoral属性应用于Testimonial类中的Quote属性,并将Unlimited作为属性的参数传递。

C#

// ...

namespace SimpleProjectManager.Module.BusinessObjects {
    // ...
    public class Testimonial {

        [FieldSize(FieldSizeAttribute.Unlimited)]
        public virtual string Quote { get; set; }

        // ...
    }
}

2.Run the application and open the Testimonial Detail View. The Quote property editor now supports multi-line input:
运行应用程序并打开Testimonial Detail View。Quote属性编辑器现在支持多行输入:

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

Use the Model Editor(使用模型编辑器)

XAF exports data model settings to the application’s metadata (Application Model). If you do not want to define the application’s UI structure and behavior in your data model code, edit the application metadata in the Model Editor. Each project stores metadata settings as XML markup in XAMFL files. These files form the Application Model’s layered structure.
XAF将数据模型设置导出到应用程序的元数据(应用程序模型)。如果不想在数据模型代码中定义应用程序的UI结构和行为,请在模型编辑器中编辑应用程序元数据。每个项目都将元数据设置存储为XAMFL文件中的XML标记。这些文件构成应用程序模型的分层结构。

Follow the steps below to change the Customer object’s caption in the Model Editor:
按照以下步骤在模型编辑器中更改客户对象的标题:

1.In the SimpleProjectManager.Module project, double-click the Model.DesignedDiffs.xafml file to open it in the Model Editor.
在SimpleProjectManager模块项目中,双击Model. DesignedDiffs.xafml文件以在模型编辑器中打开它。

2.In the Model Editor node tree, navigate to the BOModel | SimpleProjectManager.Module.BusinessObjects | Customer node and set the ObjectCaptionFormat property to {0:FullName}.
在模型编辑器节点树中,导航到BOModel | SimpleProjectManager.Module.BusinessObjects | Customer节点,并将ObjectCaptionFormat属性设置为{0:FullName}。
在这里插入图片描述
3.Run the application. The caption of the Customer Detail View now displays the FullName property value.
运行应用程序。客户详细信息视图的标题现在显示FullName属性值。

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

Define Custom Logic and UI Elements(定义自定义逻辑和UI元素)

You can use the Model Editor and built-in attributes to change UI element and control options. Alternatively, you can create Controllers and Actions in code to replace the application’s default UI elements or implement custom business logic.
您可以使用模型编辑器和内置属性来更改UI元素和控件选项。或者,您可以在代码中创建控制器和操作来替换应用程序的默认UI元素或实现自定义业务逻辑。

A Controller is a component you use to change application flow, customize UI elements, and implement custom user interaction. Controllers can include Actions. XAF renders Actions in the UI as interactive elements, such as buttons or menu items.
Controller是用于更改应用程序流程、自定义UI元素和实现自定义用户交互的组件。控制器可以包含Actions。XAF将UI中的Actions呈现为交互式元素,例如按钮或菜单项。

Follow the steps below to implement a SimpleAction that allows users to mark the selected task as completed and sets the EndDate property of the ProjectTask object to the current date and time:
按照以下步骤实现SimpleAction,允许用户将选定的任务标记为已完成,并将ProjectTask对象的EndDate属性设置为当前日期和时间:

1.In the Solution Explorer, go to the MySolution.Module project, right-click the Controllers folder, and choose Add DevExpress Item | New Item… from the context menu to invoke the Template Gallery. Select the XAF Controllers | View Controller Visual Studio template, specify ProjectTaskController as the new item’s name, and click Add Item.
在解决方案资源管理器中,转到MySolutions. Module项目,右键单击控制器文件夹,然后从上下文菜单中选择Add DevExpress Item | New Item…以调用模板库。选择the XAF Controllers | View Controller Visual Studio template,将ProjectTaskController指定为新项目的名称,然后单击添加项目。

2.Visual Studio displays an autogenerated ProjectTaskController.cs file with a View Controller declaration. Add the following code to the controller constructor:
Visual Studio显示带有View Controller声明的自动生成的ProjectTaskController. cs文件。将以下代码添加到控制器构造函数:

C#

using DevExpress.ExpressApp;
using SimpleProjectManager.Module.BusinessObjects;

namespace SimpleProjectManager.Module.Controllers {

    public class ProjectTaskController : ViewController {

        public ProjectTaskController() {
            // Specify the type of objects that can use the Controller.
            TargetObjectType = typeof(ProjectTask);
            // Activate the Controller in any type of View.
            TargetViewType = ViewType.Any;

            SimpleAction markCompletedAction = new SimpleAction(this, "MarkCompleted", 
                DevExpress.Persistent.Base.PredefinedCategory.RecordEdit) {
                TargetObjectsCriteria = 
                (CriteriaOperator.FromLambda<ProjectTask>(t => t.Status != ProjectTaskStatus.Completed)).ToString(),
                ConfirmationMessage =
                "Are you sure you want to mark the selected task(s) as 'Completed'?",
                ImageName = "State_Task_Completed"
            };

            markCompletedAction.SelectionDependencyType = SelectionDependencyType.RequireMultipleObjects;

            markCompletedAction.Execute += (s, e) => {
                foreach (ProjectTask task in e.SelectedObjects) {
                    task.EndDate = DateTime.Now;
                    task.Status = ProjectTaskStatus.Completed;
                    View.ObjectSpace.SetModified(task);
                }
                View.ObjectSpace.CommitChanges();
                View.ObjectSpace.Refresh();
            };
        }
    }

    // ...
}

In the code above, the Object Space’s IObjectSpace.CommitChanges method commits changes to the database. An Object Space entity is an ORM-independent implementation of the Repository and Unit Of Work design patterns. Object Space allows you to query or modify data in the transaction. Refer to the following help topic for information on other Object Space methods: Create, Read, Update and Delete Data.
在上面的代码中,Object Space的IObjectSpace.CommitChanges方法向数据库提交更改。Object Space实体是Repository和Unit Of Work设计模式的与ORM无关的实现。Object Space允许您查询或修改事务中的数据。有关其他Object Space方法的信息,请参阅以下帮助主题:创建、读取、更新和删除数据。

Run the application and mark the selected task as completed.
运行应用程序并将选定的任务标记为已完成。

ASP.NET Core Blazor
在这里插入图片描述
Windows Forms
在这里插入图片描述
When you apply this action to multiple objects, it iterates through the selected objects, modifies their properties, commits changes to the database, and refreshes the screen.
当您将此操作应用于多个对象时,它会遍历选定的对象、修改它们的属性、将更改提交到数据库并刷新屏幕。

Next Lesson(下一课)

Reuse Implemented Functionality
重用实现的功能

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1933809.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

解决PDF文件无法打印的困扰:快速排查与修复指南

在日常工作和学习中&#xff0c;PDF文件因其跨平台兼容性和良好的格式保持特性而广受欢迎。然而&#xff0c;当我们急需打印一份重要的PDF文件时&#xff0c;却遇到了“PDF无法打印”的尴尬情况&#xff0c;这无疑会让人感到焦急。别担心&#xff0c;本文将为你提供一系列快速排…

摄像馆唯美结婚摄影团队网站模版源码 自适应网站源码系统 前后端分离 带完整的安装代码包以及搭建教程

系统概述 摄像馆唯美结婚摄影团队网站模版源码&#xff0c;是一款集美观性、功能性与易用性于一体的网站解决方案。该系统采用最新的前端技术栈&#xff0c;如HTML5、CSS3、JavaScript等&#xff0c;结合响应式设计理念&#xff0c;确保网站能够在不同尺寸的设备上&#xff08…

在 Apifox 中如何高效批量添加接口请求 Body 参数?

在使用 Apifox 进行 API 设计时&#xff0c;你可能会遇到需要添加大量请求参数的情况。想象一下&#xff0c;如果一个接口需要几十甚至上百个参数&#xff0c;若要在接口的「修改文档」里一个个手动添加这些参数&#xff0c;那未免也太麻烦了&#xff0c;耗时且易出错。这时候&…

Python实现人脸识别

直接上代码&#xff1a; import face_recognition import time from PIL import Image, ImageDraw def faceRecognition(fileName): # 加载图片image face_recognition.load_image_file(fileName)# 人脸定位beginTime time.time()face_locations face_recognition.face_lo…

Python酷库之旅-第三方库Pandas(024)

目录 一、用法精讲 61、pandas.to_numeric函数 61-1、语法 61-2、参数 61-3、功能 61-4、返回值 61-5、说明 61-6、用法 61-6-1、数据准备 61-6-2、代码示例 61-6-3、结果输出 62、pandas.to_datetime函数 62-1、语法 62-2、参数 62-3、功能 62-4、返回值 62-…

为ppt中的文字配色

文字的颜色来源于ppt不可删去的图像的颜色 从各类搜索网站中搜索ppt如何配色&#xff0c;有如下几点&#xff1a; 1.可以使用对比色&#xff0c;表示强调。 2.可以使用近似色&#xff0c;使得和谐统一。 3.最好一张ppt中&#xff0c;使用的颜色不超过三种主要颜色。 但我想强调…

hot100 | 十四、贪心

1-leetcode121. 买卖股票的最佳时机 注意&#xff1a; Labuladong的套路太厉害了&#xff0c;分析的很清晰状态转移方程 public int maxProfit(int[] prices) {int n prices.length;int[][] dp new int[n][2];for (int i 0; i < n; i) {if (i-1 -1){// base casedp[…

【C语言】结构体,枚举,联合超详解!!!

目录 结构体 结构体声明 结构体成员的访问 结构体自引用 结构体变量定义&#xff0c;初始化&#xff0c;传参 结构体内存对齐 位段 枚举 联合(共用体) 结构体 结构体声明 1. 概念 1. 结构体是一些值的集合&#xff0c;这些值称为成员变量。 2. 结构体的每个成员可…

基于SpringBoot+Vue的广场舞团系统(带1w+文档)

基于SpringBootVue的广场舞团系统(带1w文档) 基于SpringBootVue的广场舞团系统(带1w文档) 广场舞团&#xff0c;为用户随时随地查看广场舞团信息提供了便捷的方法&#xff0c;更重要的是大大的简化了管理员管理广场舞团信息的方式方法&#xff0c;更提供了其他想要了解广场舞团…

Java强软弱虚引用的特点以及应用场景(面试重点)

强&#xff1a;即使OOM也不回收软&#xff1a;内存溢出前回收弱&#xff1a;只要垃圾收集就死虚&#xff1a;对垃圾收集没关系&#xff0c;只有得到通知&#xff08;插眼&#xff0c;也操作不了对象、只能看到它还活着&#xff09; 一、软引用 代码示例&#xff1a; public cl…

快手开源LivePortrait,实现表情姿态极速迁移,GitHub 6.5K Star

近日&#xff0c;快手可灵大模型团队开源了名为LivePortrait的可控人像视频生成框架&#xff0c;能够准确、实时地将驱动视频的表情、姿态迁移到静态或动态人像视频上&#xff0c;生成极具表现力的视频结果。如下动图所示&#xff1a; 来自网友测试LivePortrait 来自网友测试Li…

【Linux】Linux进程揭秘:从理论到实践的深度探索之旅

目录 前言&#xff1a;操作系统简介 概念 设计目的 理解 进程&#xff1a;程序的执行之魂 进程和程序的联系与区别 描述进程-PCB 进程的标识符 进程状态 状态转换 僵尸进程 孤儿进程 前言&#xff1a;操作系统简介 概念 操作系统&#xff08;英语&#xff1a;Opera…

PyTorch高级特性与性能优化

PyTorch高级特性与性能优化 引言&#xff1a; 在深度学习项目中&#xff0c;使用正确的工具和优化策略对于实现高效和有效的模型训练至关重要。PyTorch&#xff0c;作为一个流行的深度学习框架&#xff0c;提供了一系列的高级特性和性能优化方法&#xff0c;以帮助开发者充分利…

C#实现数据采集系统-ModbusTCP查询报文分析和实现、通信实现、测试项目

ModbusTcp的应用 Modbus是工业通信协议中广泛使用的协议,大部分设备都支持。Modbus TCP是一种基于TCP/IP网络的工业通信协议,它是Modbus协议的一种变种,专门设计用于在网络上传输数据。 Modbus TCP/IP保留了Modbus串行协议的数据结构和功能特性,同时利用了TCP/IP网络的高…

​污水处理厂空气质量监测——破解恶臭难题的科技钥匙

​ ​引言 ​ ​在城市化进程中&#xff0c;污水处理厂作为净化生活与工业废水的关键设施&#xff0c;扮演着至关重要的角色。然而&#xff0c;随着处理规模的不断扩大&#xff0c;污水处理厂的空气质量问题&#xff0c;尤其是恶臭问题&#xff0c;逐渐成为困扰周边居民和…

spark 事件总线listenerBus

事件总线基本流程 图片来源&#xff1a;https://blog.csdn.net/sinat_26781639/article/details/105012302 LiveListenerBus创建 在sparkContext初始化中创建LiveListenerBus对象。 主要变量有两个 queues&#xff1a;事件队列&#xff0c;里面存放四个队列&#xff0c;每…

python gradio 的输出展示组件

HTML&#xff1a;展示HTML内容&#xff0c;适用于富文本或网页布局。JSON&#xff1a;以JSON格式展示数据&#xff0c;便于查看结构化数据。KeyValues&#xff1a;以键值对形式展示数据。Label&#xff1a;展示文本标签&#xff0c;适用于简单的文本输出。Markdown&#xff1a;…

独立游戏《星尘异变》UE5 C++程序开发日志6——实现存档和基础设置系统

目录 一、存档类 1.创建一个SaveGame类 2.存储关卡内数据 3.加载关卡数据 4.关于定时器 5.存储全局数据 6.加载全局数据 二、存档栏 1.存档栏的数据结构 2.创建新存档 3.覆盖已有存档 4.删除存档 三、游戏的基础设置 1.存储游戏设置的数据结构 2.初始化设置 3.…

JavaScript基础 第四弹 学习笔记

函数 1、为什么需要函数&#xff1f;可以实现代码复用&#xff0c;提高开发效率。 函数的定义 &#xff1a;函数function&#xff0c;是被设计为执行特定任务的代码块。 函数可以把具有相同或相似逻辑的代码‘包裹’起来&#xff0c;通过函数调用执行这些被“包裹”的代码逻…

羊大师:羊奶精华,补钙免疫,养颜促消化

在浩瀚的自然馈赠中&#xff0c;羊奶以其独特的精华&#xff0c;成为了现代人追求健康生活的优选。它不仅仅是一种饮品&#xff0c;更是大自然赋予我们的宝贵滋养圣品。 补钙免疫&#xff0c;守护健康基石 羊奶中富含的钙质&#xff0c;是构建强健骨骼的基石。其高吸收率的特性…