A string that is semicolon separated names of the Views in which the conditional appearance rule is in effect.
Remarks
The Context property can have the following values.
Context
Appearance Rule's Activity Scope
Example
A predefined context - "DetailView", "ListView" or "Any".
Detail Views, List Views or all Views, respectively.
Any
A semicolon-separated list of View identifiers.
Specified Views only.
MyClass_ListView;MyClass_DetailView
The "Any" predefined context, followed by a semicolon-separated list of View identifiers.
All Views except the Views specified via View identifiers.
Any;MyClass_ListView;MyClass_LookupListView
The "DetailView" or "ListView" predefined context, followed by a semicolon-separated list of View identifiers.
All Detail Views or List Views respectively, in addition to Views specified via View identifiers.
DetailView;MyClass_ListView
By default, Context is set to "Any".
Examples
Example 1
According to the rule demonstrated in the example below, the "ProductParameters" layout group caption in the Product Detail View will be displayed in Blue font color when the Category property is set to "Seafood".
using DevExpress.ExpressApp.ConditionalAppearance;
//...
[Appearance("LayoutGroupColoredInDetailView", AppearanceItemType = "LayoutItem",
TargetItems = "ProductParametersLayoutGroup", Criteria = "Category = 'Seafood'",
Context = "Product_DetailView", FontColor = "Blue")]
public class Product : BaseObject {
public Product(Session session) : base(session) { }
public string Name {
//...
}
public decimal Price {
//...
}
public ProductStatus Status {
//...
}
public Category Category {
//...
}
}
[DefaultProperty(nameof(Name))]
public class Category : BaseObject {
public Category(Session session) : base(session) {}
public string Name {
//...
}
}
Imports DevExpress.ExpressApp.ConditionalAppearance
'...
<Appearance("LayoutGroupColoredInDetailView", AppearanceItemType := "LayoutItem",
TargetItems := "ProductParametersLayoutGroup", Criteria := "Category = 'Seafood'",
Context := "Product_DetailView", FontColor := "Blue")> _
Public Class Product
Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public ReadOnly Property Name() As String
'...
End Property
Public ReadOnly Property Price() As Decimal
'...
End Property
Public ReadOnly Property Status() As ProductStatus
'...
End Property
Public ReadOnly Property Category() As Category
'...
End Property
End Class
<DefaultProperty(NameOf(Name))> _
Public Class Category
Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public ReadOnly Property Name() As String
'...
End Property
End Class
Example 2
According to the rule demonstrated in the example below, the Product objects whose Price is more than 50 will be displayed in Red background using Maroon font color in List Views.
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 {
//...
}
}
Imports DevExpress.ExpressApp.ConditionalAppearance
'...
<Appearance("RedPriceObject", AppearanceItemType := "ViewItem", TargetItems := "*", _
Criteria := "Price>50", Context := "ListView", BackColor := "Red", _
FontColor := "Maroon", Priority := 2)> _
Public Class Product
Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public ReadOnly Property Name() As String
'...
End Property
Public ReadOnly Property Price() As Decimal
'...
End Property
Public ReadOnly Property Status() As ProductStatus
'...
End Property
Public ReadOnly Property Category() As Category
'...
End Property
End Class
Example 3
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;
}
}
Imports DevExpress.ExpressApp.ConditionalAppearance
'...
<Appearance("ActionVisibility", AppearanceItemType := "Action", _
TargetItems := "Product.Deactivate", _
Criteria := "Status = 'Inactive'", Context := "Any", Visibility := ViewItemVisibility.Hide)> _
Public Class Product
Inherits BaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public ReadOnly Property Status() As ProductStatus
'...
End Property
<Action(PredefinedCategory.RecordEdit, Caption := "Deactivate Product...", AutoCommit := True,
TargetObjectsCriteria := "Status = 'Active'", _
SelectionDependencyType := MethodActionSelectionDependencyType.RequireSingleObject)> _
Public Sub Deactivate()
Status = ProductStatus.Inactive
End Sub
End Class
To see the Appearance attribute in action, refer to the FeatureCenter demo installed with XAF. This demo is located in the %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\FeatureCenter folder by default.