Back to Devexpress

AppearanceAttribute.Priority Property

expressappframework-devexpress-dot-expressapp-dot-conditionalappearance-dot-appearanceattribute-a8861d19.md

latest5.8 KB
Original Source

AppearanceAttribute.Priority Property

Specifies the priority of the conditional appearance rule generated from the current attribute instance. Used when several rules affect the same UI element.

Namespace : DevExpress.ExpressApp.ConditionalAppearance

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

NuGet Package : DevExpress.Persistent.Base

Declaration

csharp
public int Priority { get; set; }
vb
Public Property Priority As Integer

Property Value

TypeDescription
Int32

An integer value specifying the volume of the conditional appearance rule.

|

Remarks

There can be several conditional appearance rules affecting the UI element specified by AppearanceAttribute.TargetItems. In this instance, the rules are applied according to the volume specified by the Priority property. Rules with a higher volume may override changes made by rules with a lower volume.

If the Priority is not specified, a rule that applies customization always has priority over a rule that cancels customization for the same editor.

Note

Priority is ignored for rules that change an item’s visibility, Enabled state and font style.

  • Enabled : False has higher priority than True
  • Visibility : Hide has higher priority than ShowEmptySpace; ShowEmptySpace has higher priority than Visible.
  • FontStyle : Regular has lowest priority. Other styles are combined by disjunction.

In the following examples, the Category property is displayed in a Maroon font according to the rule from the first example, and the same property is displayed in a Blue font according to the rule from the second example. When both these rules are applied to the Product class, the priority should be set. Here, the rule from the first example has the higher volume (Priority = 2). So, Category is shown in maroon.

Example 1

The following code snippet changes the Product objects to maroon on a red background in List Views when the product’s price exceeds 50:

csharp
using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("RedPriceObject", AppearanceItemType = "ViewItem", TargetItems = "*",
    Criteria = "Price>50", Context = "ListView", BackColor = "Red",
        FontColor = "Maroon", Priority = 2)]
public class Product : BaseObject {
    public virtual string Name { get; set; }
    public virtual decimal Price { get; set; }
    public virtual ProductStatus Status { get; set; }
    public virtual Category Category { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
csharp
using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("RedPriceObject", AppearanceItemType = "ViewItem", TargetItems = "*",
    Criteria = "Price>50", Context = "ListView", BackColor = "Red",
        FontColor = "Maroon", Priority = 2)]
public class Product : BaseObject {
    public Product(Session session) : base(session) { }
    public string Name {
        //...
    }
    public decimal Price {
        //...
    }
    public ProductStatus Status {
        //...
    }
    public Category Category {
        //...
    }
}

Example 2

The following code snippet changes the Category property in List Views to blue when its value is “Seafood”:

csharp
using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("CategoryColoredInListView", AppearanceItemType = "ViewItem", TargetItems = "Category",
 Criteria = "Category = 'Seafood'", Context = "ListView", FontColor = "Blue", Priority = 1)]
public class Product : BaseObject {
    public virtual Category Category { get; set; }
}

[DefaultProperty(nameof(Name))]
public class Category : BaseObject {
    public virtual string Name { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
csharp
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(nameof(Name))]
public class Category : BaseObject {
    public Category(Session session) : base(session) {}
    public string Name {
        //...
    }
}

Implements

Priority

See Also

Conditional Appearance (Manage UI State)

AppearanceAttribute Class

AppearanceAttribute Members

DevExpress.ExpressApp.ConditionalAppearance Namespace