AppearanceAttribute.Criteria Property

Specifies the criteria string used when determining whether AppearanceAttribute.TargetItems should be affected by the conditional appearance rule generated from the current attribute.

Namespace: DevExpress.ExpressApp.ConditionalAppearance

Assembly: DevExpress.Persistent.Base.v18.2.dll

Declaration

public string Criteria { get; set; }
Public Property Criteria As String

Property Value

Type Description
String

A string representing the criterion under which the conditional appearance rule is in effect.

To learn how to declare string criteria, refer to the Ways to Build Criteria topic. To learn how to use Function Criteria Operators in string criteria, refer to the Function Criteria Operators topic.

When it's inappropriate for you to pass the required criteria as the attribute's Criteria parameter, implement a method in the target business class and apply the Appearance to it. In this instance, the attribute's Criteria parameter is ignored. The conditional appearance rule generated from this attribute is in effect when the method returns true. For details, refer to the Method property description.

Examples

Example1

According to the rule demonstrated in the example below, the Category property in List Views will be displayed in Blue font color when its value is "Seafood".

using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("CategoryColoredInListView", AppearanceItemType = "ViewItem", TargetItems = "Category",
 Criteria = "Category = 'Seafood'", Context = "ListView", FontColor = "Blue", Priority = 1)]
public class Product : BaseObject {
    public Product(Session session) : base(session) { }
    public Category Category {
        //...
    }
}
[DefaultProperty("Name")]
public class Category : BaseObject {
    public Category(Session session) : base(session) {}
    public string Name {
        //...
    }
}

Example2

According to the rule demonstrated in the example below, a Product's Deactivate Action will be hidden when the Status property is set to "Inactive" in all Product Views. Note that the Action ID specified in this rule contains the class name ("Product.Deactivate"), because the Deactivate Action is declared using the ActionAttribute. If an Action is declared in a Controller, specify its ID without the class name, e.g., "Delete" or "Unlink".

using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("ActionVisibility", AppearanceItemType = "Action",
    TargetItems = "Product.Deactivate",
        Criteria = "Status = 'Inactive'", Context = "Any", Visibility = ViewItemVisibility.Hide)]
public class Product : BaseObject {
    public Product(Session session) : base(session) { }
    public ProductStatus Status {
        //...
    }   
    [Action(PredefinedCategory.RecordEdit, Caption = "Deactivate Product...", AutoCommit = true,
     TargetObjectsCriteria = "Status = 'Active'",
      SelectionDependencyType = MethodActionSelectionDependencyType.RequireSingleObject)]
    public void Deactivate() {
        Status = ProductStatus.Inactive;
    }
}

There are more examples demonstrated in the Declare Conditional Appearance Rules in Code topic. See these examples in the Feature Center demo installed with the eXpressApp Framework, or refer to the Feature Center demo online.

See Also