Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

AppearanceAttribute.Method Property

Specifies the name of the business class method used to determine whether the Conditional Appearance rule generated from this attribute is currently active.

Namespace: DevExpress.ExpressApp.ConditionalAppearance

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

Declaration

public string Method { get; set; }

Property Value

Type Description
String

A string specifying the name of the method used to determine whether the rule is active.

Remarks

When you need to create a complex rule that cannot be specified using the AppearanceAttribute.Criteria property, you can implement a business class method that takes no parameters and returns a Boolean value specifying whether the rule is currently active (the Criteria will be ignored in this case). You do not need to specify the Method parameter when the AppearanceAttribute attribute is directly applied to the business class method.

Example

According to the rule demonstrated in the example below, the Product objects in List Views will be displayed in Green background using Black font color when the RuleMethod returns true.

using DevExpress.ExpressApp.ConditionalAppearance;
//...
public class Product : BaseObject {
    public Product(Session session) : base(session) { }
    public decimal Price {
        //...
    }
    public ProductStatus Status {
        //...
    }
    [Appearance("RuleMethod", AppearanceItemType = "ViewItem", TargetItems = "*", Context = "ListView",
     BackColor = "Green", FontColor = "Black")]
    public bool RuleMethod() {
        if (Price < 10 && Status == ProductStatus.Active) {
            return true;
        }
        else {
            return false;
        }
    }
}

Tip

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 in the %PUBLIC%\Documents\DevExpress Demos 21.2\Components\eXpressApp Framework\FeatureCenter folder, or refer to the Feature Center demo online.

Static Method

The appearance rule is inactive when the target method is non-static and the target object is null. If you declare the method as static, the method can optionally accept a parameter that provides access to the context object:

public static bool MyMethod(object contextObject) {
    if(contextObject != null) {
        // calculate and return result based on context
    }
    else {
       // return default result
    }
}

Implements

See Also