In this lesson, you will learn how to format data that satisfies the specified criteria. For this purpose, the Conditional Appearance module will be added to the application. You will highlight the DemoTask objects whose Status property is not set to Completed. In addition, you will highlight the Priority property when it contains the High value.

在本课中,您将学习如何设置满足指定条件的数据的格式。为此,条件外观模块将添加到应用程序中。您将突出显示其 Status 属性未设置为"已完成"的演示任务对象。此外,当"Priority"属性包含"高"值时,将突出显示该属性。

  • Add the Conditional Appearance module to your MySolution.Module project. For this purpose, double-click the Module.cs (Module.vb) file, located in the MySolution.Module project. The Module Designer will be invoked. In the Toolbox, navigate to the DX.19.2: XAF Modules tab, and drag the ConditionalAppearanceModule item from this tab to the Designer's Required Modules section, as shown below.
  • 将条件外观模块添加到 MySolution.模块项目中。为此,双击位于 MySolution.module 项目中的Module.cs(Module.vb)文件。将调用模块设计器。在工具箱中,导航到 DX.19.2:XAF 模块选项卡,并将条件外观模块项从此选项卡拖动到"设计器的必需模块"部分,如下所示。

  • Rebuild your solution after you have made changes in the Module Designer.
  • To declare a conditional appearance rule for the DemoTask class, apply the AppearanceAttribute attribute to this class. As the first parameter, specify the Appearance Rule identifier (e.g., "FontColorRed"). Then, specify the following parameters.

  • 在模块设计器中进行更改后重新生成解决方案。

  • 要声明 DemoTask 类的条件外观规则,请将"外观属性"属性应用于此类。作为第一个参数,请指定外观规则标识符(例如,"FontColorRed")。然后,指定以下参数。

Parameter Settings
Target UI elements to be affected by the rule. Set the AppearanceAttribute.AppearanceItemType parameter to "ViewItem" and the AppearanceAttribute.TargetItems parameter to "*". This means that the rule generated from the attribute will affect all DemoTask properties displayed in the current View.
Conditions under which the rule must be in effect. Set the AppearanceAttribute.Context parameter to "ListView" and the AppearanceAttribute.Criteria parameter to "Status!='Completed'". In this instance, the rule generated from the attribute will be in effect in a DemoTask List View for the object whose Status property is not set to Completed.
Conditional appearance applied by the rule. Set the AppearanceAttribute.FontColor named parameter to "Red".

The following code demonstrates the applied attribute and its parameters to the DemoTask class, that was declared in BusinessObjects\DemoTask.cs (DemoTask.vb) file.

以下代码演示了在 BusinessObjects_DemoTask.cs (DemoTask.vb) 文件中声明的 DemoTask 类所应用的属性及其参数。

using DevExpress.ExpressApp.ConditionalAppearance;
// ...
[Appearance("FontColorRed", AppearanceItemType = "ViewItem", TargetItems = "*", Context = "ListView",
Criteria = "Status!='Completed'", FontColor = "Red")]
public class DemoTask : Task {
// ...
}

Note 注意

The Criteria value must be specified using the Criteria Language Syntax.

必须使用"条件语言语法"指定条件值。

  • Apply the AppearanceAttribute attribute to the DemoTask class' Priority property. As the first positional parameter, specify the Appearance Rule identifier (e.g., "PriorityBackColorPink"). Then, specify the following parameters.

  • 将外观属性应用于演示任务类的"优先级"属性。作为第一个位置参数,请指定外观规则标识符(例如,"优先级回颜色粉红")。然后,指定以下参数。
  • Specify the target UI elements to be affected by the rule

    Set the AppearanceAttribute.AppearanceItemType parameter to "ViewItem". This means that the rule generated from the attribute will affect the Priority property displayed in the current View.

  • 指定要受规则影响的目标 UI 元素
    将外观属性.外观项目类型参数设置为"查看项目"。这意味着从该属性生成的规则将影响当前视图中显示的"优先"属性。
  • Specify the conditions under which the rule must be in effect

    Set the AppearanceAttribute.Context parameter to "Any" and the AppearanceAttribute.Criteria parameter to "Priority=2". In this instance, the rule generated from the attribute will affect the Priority property when it is set to 2 (High) in any DemoTask View.

  • 指定规则必须生效的条件
    将"外观属性.上下文"参数设置为"任意",将"外观属性"标准参数设置为"优先级{2}"。在这种情况下,从该属性生成的规则将影响"优先"属性,当它在任何演示任务视图中设置为 2(高)。
  • Specify the conditional appearance applied by the rule

    Set the AppearanceAttribute.BackColor parameter to "255, 240, 240".

  • 指定规则应用的条件外观
    将外观属性.BackColor 参数设置为"255、240、240"。

The following code demonstrates the applied attribute and its parameters.

以下代码演示应用的属性及其参数。

public class DemoTask : Task {
// ...
[Appearance("PriorityBackColorPink", AppearanceItemType = "ViewItem", Context = "Any",
Criteria = "Priority=2", BackColor = "255, 240, 240")]
public Priority Priority {
// ...
}
// ...
}
  • Run the WinForms or ASP.NET application. The DemoTask List View and Detail View data will be highlighted, as demonstrated in the following image.

  • 运行 WinForms 或ASP.NET应用程序。演示任务列表视图和详细信息视图数据将突出显示,如下图所示。

Note 注意
Appearence Rules that are declared in code are available in the Model Editor. To access them, you can run the Model Editor for the MySolution.Module project. Navigate to the BOModel | DemoTask | AppearanceRules node. This node has two child nodes (FontColorRed and PriorityBackColorPink) that are generated automatically from Appearance attributes applied to the DemoTask class and the DemoTask.Priority property. You can create new Appearance Rules directly in the Model Editor by adding child nodes to the AppearanceRules node.

在代码中声明的显示规则在模型编辑器中可用。要访问它们,您可以运行 MySolution.模块项目的模型编辑器。导航到 BOModel |演示任务 |外观规则节点。此节点有两个子节点(FontColorRed 和优先级BackColorPink),它们从应用于 DemoTask 类和 DemoTask.Priority 属性的外观属性自动生成。通过将子节点添加到"外观规则"节点,可以直接在模型编辑器中创建新的外观规则。

You can see the changes made in the lesson in the DemoTask.cs (DemoTask.vb) file located in the MainDemo.Module project of the MainDemo solution. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/

您可以在 mainDemo 解决方案的 MainDemo.模块项目中的DemoTask.cs (DemoTask.vb) 文件中看到本课中所做的更改。主演示应用程序安装在%PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/

.

Highlight List View Objects 突出显示列表视图对象的更多相关文章

  1. Apply Grouping to List View Data 将分组应用于列表视图数据

    This lesson will teach you how to apply grouping to List View data. For this purpose, you will group ...

  2. Change Field Layout and Visibility in a List View 在列表视图中更改字段布局和可见性

    This lesson will guide you through the steps needed to select columns displayed in the List View. Fo ...

  3. [Swift通天遁地]六、智能布局-(2)视图对象的尺寸和位置相对约束

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  4. Display a Detail View with a List View 主子视图-列表视图与详细信息视图同时显示

    In this lesson, you will learn how to display a Detail View together with a List View. For this purp ...

  5. How to: Display a List of Non-Persistent Objects in a Popup Dialog 如何:在弹出对话框中显示非持久化对象列表

    This example demonstrates how to populate and display a list of objects that are not bound to the da ...

  6. Make a List View Editable 使列表视图可编辑

    In this lesson, you will learn how to make a List View editable. For this purpose, the DemoTask List ...

  7. Add a Preview to a List View将预览添加到列表视图

    In this lesson, you will learn how to show a preview section in a List View's grid. For this purpose ...

  8. Android列表视图(List View)

    Android列表视图(ListView) ListView是一个显示滚动项列表的示视图组(viewgroup),通过使用适配器(Adapter)把这些列表项自动插入到列表中.适配器比如从一个数组或是 ...

  9. .NET MVC+ EF+LINQ 多表联查VIEW显示列表

    1.VIEW 页面显示代码 <link href="~/Content/bootstrap.css" rel="stylesheet" /> < ...

随机推荐

  1. Python协程与Go协程的区别二

    写在前面 世界是复杂的,每一种思想都是为了解决某些现实问题而简化成的模型,想解决就得先面对,面对就需要选择角度,角度决定了模型的质量, 喜欢此UP主汤质看本质的哲学科普,其中简洁又不失细节的介绍了人类 ...

  2. 如何用vue-cli3脚手架搭建一个基于ts的基础脚手架

    目录 准备工作 搭建项目 vue 中 ts 语法 项目代理及 webpack 性能优化 其他 忙里偷闲,整理了一下关于如何借助 vue-cli3 搭建 ts + 装饰器 的脚手架,并如何自定义 web ...

  3. flutter最简单轻量便捷的路由管理方案NavRouter

    大家好,我是CrazyQ1,今天给大家推荐一个路由管理方案,用的非常不错的,叫nav_router. 项目地址是:https://github.com/fluttercandies/nav_route ...

  4. 洛谷 P1920 成功密码 题解

    这是蒟蒻的第一篇题解,(之前的都没过,估计这篇也过不了 回到正题 这题,本蒟蒻第一眼看到以后,就决定咦,这不是模拟吗? 看到世界范围,嗯,打扰了. 扯回正题 首先,暴力肯定是A不了的(至少我A不了 但 ...

  5. 并查集 2019年8月10日计蒜客联盟周赛 K.数组

    题目链接:https://nanti.jisuanke.com/t/40860 题意:给一个长度为n的数组a[],n<1e5,a[i]<1e5 三个操作: 1 x y:把所有值为x的数据改 ...

  6. 这些C++常用内置函数你会几个??

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:Regina520  新手注意:如果你C++学的不好,可以去拿我的C+ ...

  7. Mybatis代码生成器Mybatis-Generator使用详解

    前提 最近在做创业项目的时候因为有比较多的新需求,需要频繁基于DDL生成Mybatis适合的实体.Mapper接口和映射文件.其中,代码生成器是MyBatis Generator(MBG),用到了My ...

  8. 深入探索Java设计模式之单例模式

    单例模式可确保在给定的时间实例中只能创建一个具有全局访问点的对象.这是面向对象编程中最常用的技术之一.尽管它很简单,但从类设计的角度来看可能是最简单的,但是在尝试实现它们之前,必须先解决一些细微的问题 ...

  9. Manjaro-kde-18.1.3安装体验

    身为Linux排名第一的版本,怎么能不安装一下亲自体验 制作启动U盘 Manjaro身为arc系列的一员,所以我选择使用raw的方式写入(其实我是在Ubuntu中用dd方式写入的,Windows用户也 ...

  10. 牛客练习赛32B Xor Path (树形dp)

    时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 给定一棵n个点的树,每个点有权值.定义表示 ...