Skip to main content
.NET 8.0+

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

AppearanceAttribute.AppearanceItemType Property

Specifies the type of UI elements affected by the conditional appearance rule created using this attribute.

Namespace: DevExpress.ExpressApp.ConditionalAppearance

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

#Declaration

public string AppearanceItemType { get; set; }

#Property Value

Type Description
String

The string representation of an AppearanceItemType enumeration value specifying the type of UI elements affected by the conditional appearance rule.

#Remarks

To specify the UI element to be affected, apply the Appearance attribute to the required business class or business class property and use the AppearanceItemType and AppearanceAttribute.TargetItems attribute parameters. For details, refer to the Declare Conditional Appearance Rules in Code topic.

These are the following possible values for the AppearanceItemType attribute parameter:

This property is set to ViewItem by default.

#Examples

#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:

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.

#Example 2.

The following code snippet changes the Category layout item’s caption in Product Detail Views to blue when the product’s category is “Seafood”:

using DevExpress.ExpressApp.ConditionalAppearance;
//...
public class Product : BaseObject {
    [Appearance("CategoryColoredInDetailView", AppearanceItemType = "LayoutItem",
         TargetItems = "Category", Criteria = "Category = 'Seafood'", Context = "DetailView",
             FontColor = "Blue")]
    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.

#Example 3.

The following code snippet disables a Product’s Deactivate Action when the Status property is set to “Inactive” in all Product Views. The Action ID specified in this rule contains the class name (“Product.Deactivate”) because the Deactivate Action is declared using the ActionAttribute. If you declare an Action in a Controller, specify its ID without the class name, for example, “Delete” or “Unlink”.

using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("ActionState", AppearanceItemType = "Action",
    TargetItems = "Product.Deactivate",
        Criteria = "Status = 'Inactive'", Context = "Any", Enabled = false)]
public class Product : BaseObject {
    public virtual ProductStatus Status { get; set; }
    [Action(PredefinedCategory.RecordEdit, Caption = "Deactivate Product...", AutoCommit = true,
     TargetObjectsCriteria = "Status = 'Active'",
      SelectionDependencyType = MethodActionSelectionDependencyType.RequireSingleObject)]
    public void Deactivate() {
        Status = ProductStatus.Inactive;
    }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

Note

When you use a Conditional Appearance Rule (for example, the Appearance attribute) to hide an Action, it remains visible in List Views. XAF displays this Action as disabled. This helps avoid complex calculations that could hinder the application’s performance.

Additional examples are available in the Declare Conditional Appearance Rules in Code topic. See these examples in the Feature Center demo installed with XAF in the %PUBLIC%\Documents\DevExpress Demos 25.1\Components\XAF\FeatureCenter.NETFramework.XPO folder, or refer to the Feature Center demo online.

#Implements

See Also