AppearanceObject Class
An appearance generated by combining all the found conditional appearance rules appropriate for the target UI element.
Namespace: DevExpress.ExpressApp.ConditionalAppearance
Assembly: DevExpress.ExpressApp.ConditionalAppearance.v19.2.dll
Declaration
public class AppearanceObject
Public Class AppearanceObject
public class AppearanceObject
Public Class AppearanceObject
public class AppearanceObject
Public Class AppearanceObject
When declaring conditional appearance rules, it may be required to customize the appearance applied to specific UI elements or under specific circumstances. For this purpose, handle the AppearanceController's AppearanceController.CustomApplyAppearance and AppearanceController.AppearanceApplied events. The ApplyAppearanceEventArgs object, passed as a parameter in the event handlers, provides access to the appearance that is about to be applied if you get it in the CustomApplyAppearance event handler, or to the appearance that has been just applied if you get it in the AppearanceApplied event handler. The appearance is represented by the AppearanceObject. It allows you to determine which customizations form the appearance applied. For this purpose, use the AppearanceObject.Enabled, AppearanceObject.Visibility, AppearanceObject.BackColor, AppearanceObject.FontColor and AppearanceObject.FontStyle properties. If you need to modify an appearance to be applied, you can get the AppearanceObject and specify its properties in the required way. This should be performed in the CustomApplyAppearance event handler. Note - if you leave the Handled parameter set to false, the modified appearance will be applied by the AppearanceController. If you set the Handled parameter to true, you should apply the modified appearance yourself. In this instance, the following code may help you perform your task:
using DevExpress.ExpressApp.ConditionalAppearance;
using DevExpress.ExpressApp.Editors;
//...
public partial class ConditionalAppearanceController : ViewController {
public ConditionalAppearanceController() {
InitializeComponent();
}
private AppearanceController appearanceController;
protected override void OnActivated() {
base.OnActivated();
appearanceController = Frame.GetController<AppearanceController>();
if (appearanceController != null) {
appearanceController.CustomApplyAppearance +=
new EventHandler<ApplyAppearanceEventArgs>(
appearanceController_CustomApplyAppearance);
}
}
void appearanceController_CustomApplyAppearance (
object sender, ApplyAppearanceEventArgs e) {
//Customize the AppearanceObject
//Apply the modified appearance
foreach(AppearanceItemBase appearanceItem in e.AppearanceObject.Items) {
appearanceItem.Apply(e.Item);
}
}
protected override void OnDeactivated() {
if (appearanceController != null) {
appearanceController.CustomApplyAppearance -=
new EventHandler<ApplyAppearanceEventArgs>(
appearanceController_CustomApplyAppearance);
}
base.OnDeactivated();
}
}
Imports DevExpress.ExpressApp.ConditionalAppearance
Imports ConditionalAppearanceExample.Module.BusinessObjects
Imports DevExpress.ExpressApp.Editors
'...
Partial Public Class ConditionalAppearanceController
Inherits ViewController
Public Sub New()
InitializeComponent()
End Sub
Private appearanceController As AppearanceController
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
appearanceController = Frame.GetController(Of AppearanceController)()
If appearanceController IsNot Nothing Then
AddHandler appearanceController.CustomApplyAppearance, _
AddressOf appearanceController_CustomApplyAppearance
End If
End Sub
Private Sub appearanceController_CustomApplyAppearance( _
ByVal sender As Object, ByVal e As ApplyAppearanceEventArgs)
'Customize the AppearanceObject
'Apply the modified appearance
For Each appearanceItem As AppearanceItemBase In e.AppearanceObject.Items
appearanceItem.Apply(e.Item)
Next appearanceItem
End Sub
Protected Overrides Sub OnDeactivated()
If appearanceController IsNot Nothing Then
RemoveHandler appearanceController.CustomApplyAppearance, _
AddressOf appearanceController_CustomApplyAppearance
End If
MyBase.OnDeactivated()
End Sub
End Class
See Also