AppearanceController.CollectAppearanceRules Event
Occurs after conditional appearance rules for the business object represented by the specified View are collected from the Application Model.
Namespace: DevExpress.ExpressApp.ConditionalAppearance
Assembly: DevExpress.ExpressApp.ConditionalAppearance.v24.2.dll
NuGet Package: DevExpress.ExpressApp.ConditionalAppearance
Declaration
Event Data
The CollectAppearanceRules event's data class is CollectAppearanceRulesEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
AppearanceRules | Provides access to the list of conditional appearance rules found for the target UI element in the Application Model. |
ContextView | Obsolete. The View in which the target UI element (view or layout item) is contained or activated (in case an Action is the target UI element). |
Name | The name of the UI element for which conditional appearance rules are collected. |
ViewInfo | Gets the information related to the current View. |
Remarks
The Application Model’s BOModel | <Class> | AppearanceRules node lists all the rules declared for properties or layout items of the corresponding business class and for Actions activated for Views of this business class. When the Appearance Controller determines which rules should be applied to a specified UI element, it first collects all rules from the appropriate BOModel | <Class> node. Then it filters them, leaving only those that are appropriate in the current context and for the specified criteria. Before the list of found rules is filtered and sorted, you can access it by handling the CollectAppearanceRules event. In the event handler, use the CollectAppearanceRulesEventArgs.AppearanceRules parameter. In addition, you can access the View in which the target UI element (View Item and Layout Item or Group) is contained, or for which the target Action is activated. Use the event handler’s CollectAppearanceRulesEventArgs.ViewInfo property. To get the name of the target UI element, use the CollectAppearanceRulesEventArgs.Name parameter.
Using this event, you can add a conditional appearance rule dynamically. However, the following problem may arise. After collecting rules for a specified UI element, the Appearance Controller caches them so that the next time the conditional appearance is refreshed for this UI element, the rules are not collected again. The CollectAppearanceRules event is raised once the rules are collected for a UI element. So, you may subscribe to the CollectAppearanceRules event late, when the rules have already been cached. In this instance, we recommend that you call the AppearanceController.ResetRulesCache method, then subscribe to the CollectAppearanceRules event and finally, call the AppearanceController.Refresh method.
To learn how the collected rules are combined and applied, refer to the AppearanceController.RefreshItemAppearance method description.
Refer to the How to: Customize the Conditional Appearance Module Behavior topic to see an example of handling this event.