Back to Devexpress

AppearanceAttribute.BackColor Property

expressappframework-devexpress-dot-expressapp-dot-conditionalappearance-dot-appearanceattribute-6d546424.md

latest4.6 KB
Original Source

AppearanceAttribute.BackColor Property

Specifies the background color of UI elements affected by the conditional appearance rule generated from this attribute instance.

Namespace : DevExpress.ExpressApp.ConditionalAppearance

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

NuGet Package : DevExpress.Persistent.Base

Declaration

csharp
public string BackColor { get; set; }
vb
Public Property BackColor As String

Property Value

TypeDescription
String

A string specifying the background color of UI elements affected by the conditional appearance rule. A value should be recognizable by the System.Drawing.ColorConverter class.

|

Remarks

The following UI elements can change their background color:

Note

We do not recommend to apply the same background color for all business class properties. This setting changes the background color of selected rows in the GridControl, so the selection is invisible when you select rows with the modified background color.

The font color depends on the current skin. Ensure that the specified background color does not make the text unreadable in certain skins. For more information about skins, refer to the following topic: IModelApplicationOptionsSkin.Skin.

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 {
        //...
    }
}

Tip

You can find examples of this functionality in the MainDemo demo included with XAF. The demo illustrates various XAF features (including Appearance attribute) and is located in the %PUBLIC%\Documents\DevExpress Demos 25.2\Components\XAF\MainDemo.NET.EFCore folder.

See Also

Conditional Appearance (Manage UI State)

AppearanceAttribute Class

AppearanceAttribute Members

DevExpress.ExpressApp.ConditionalAppearance Namespace