学习008-02-05-03 Highlight Property Editors(突出显示属性编辑器)

Highlight Property Editors(突出显示属性编辑器)

This lesson explains how to format data that satisfies the specified criteria.
本课介绍如何格式化满足指定条件的数据。

The instructions below show how to do the following:
以下说明显示了如何执行以下操作:

  • Add the Conditional Appearance module to the application.(将条件外观模块添加到应用程序。)
  • *Highlight the DemoTask objects whose Status property is not set to Completed.(*突出显示状态属性未设置为已完成的DemoTask对象。)
  • Highlight the Priority property when it contains the High value.(当优先级属性包含高值时,突出显示它。)

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

1.Add the DevExpress.ExpressApp.ConditionalAppearance NuGet package to the MySolution.Module project. See the following topic for more information on how to install DevExpress NuGet packages: Choose Between Offline and Online DevExpress NuGet Feeds.
将DevExpress. ExpressApp.ConditionalAppearanceNuGet包添加到MySolutions.Module项目。有关如何安装DevExpress NuGet包的更多信息,请参阅以下主题:在离线和在线DevExpress NuGet Feeds之间进行选择。

2.In the MySolution.Module project, open the Module.cs file and add the Conditional Appearance module:
在MySolutions. Module项目中,打开Module.cs文件并添加条件外观模块:

C#

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Updating;

namespace MySolution.Module;

public sealed class MySolutionModule : ModuleBase {
    public MySolutionModule() {
        // ...
        RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ConditionalAppearance.ConditionalAppearanceModule));
    }
    //...
}

3.Open the DemoTask class and apply the AppearanceAttribute attribute as displayed in the code sample below:
打开DemoTask类并应用外观属性,如下面的代码示例中所示:

C#

// ...
using DevExpress.ExpressApp.ConditionalAppearance;

namespace MySolution.Module.BusinessObjects {
    [Appearance("FontColorRed", AppearanceItemType = "ViewItem", TargetItems = "*",
    Context = "ListView", Criteria = "Status!='Completed'", FontColor = "Red")]
    [DefaultClassOptions]
    [ModelDefault("Caption", "Task")]
    public class DemoTask : BaseObject {
     // ...
    }
}

The first parameter of the Appearance attribute is Id — a unique appearance rule identifier. The rest of the parameters are as follows:
外观属性的第一个参数是Id——一个唯一的外观规则标识符。其余参数如下:
在这里插入图片描述

Note
Follow the Criteria Language Syntax rules to specify the Criteria value.
按照条件语言语法规则指定条件值。

4.Apply the AppearanceAttribute attribute to the Priority property of the DemoTask class. As the first positional parameter, specify the Appearance Rule identifier (e.g., PriorityBackColorPink). Then, specify other parameters.
将外观属性应用于DemoTask类的优先级属性。作为第一个位置参数,指定外观规则标识符(例如PriorityBackColorPink)。然后,指定其他参数。

C#

using DevExpress.ExpressApp.ConditionalAppearance;
//...
public class DemoTask : BaseObject {
    // ...
    [Appearance("PriorityBackColorPink", AppearanceItemType = "ViewItem",
    Context = "Any", Criteria = "Priority=2", BackColor = "255, 240, 240")]
    public virtual Priority Priority { get; set; }
    // ...
}

The first parameter of the Appearance attribute is once again Id — a unique appearance rule identifier. The rest of the parameters are as follows:
外观属性的第一个参数再次是Id——一个唯一的外观规则标识符。其余参数如下:
在这里插入图片描述

5.Run the application. The DemoTask List View and Detail View display a conditional appearance:
运行应用程序。DemoTask List View和Detail View显示条件外观:

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

Windows Forms
在这里插入图片描述

Note
You can access these appearance rules from the Model Editor. Open the Model.DesignedDiffs.xafml file and navigate to the BOModel | DemoTask | AppearanceRules node. This node has two child nodes: FontColorRed and PriorityBackColorPink. XAF generates them automatically from the Appearance attributes applied to the DemoTask class and the DemoTask.Priority property. To create a new appearance rule in the Model Editor, add a child node to the AppearanceRules node.
您可以从模型编辑器访问这些外观规则。打开Model. DesignedDiffs.xafml文件并导航到BOModel|DemoTask|外观规则节点。该节点有两个子节点:FontColorRed和PriorityBackColorPink。XAF会根据应用于DemoTask类的外观属性和DemoTask.优先属性自动生成它们。要在模型编辑器中创建新的外观规则,请向外观规则节点添加一个子节点。

Next Lesson(下一课)

Attach Files to Objects
将文件附加到对象

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

汤姆•猫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值