Dennis (DevExpress Support)
03.10.2010
We have introduced the CustomApplyAppearance and AppearanceApplied events into the DevExpress.ExpressApp.ConditionalAppearance.AppearanceController class.
Both use the DevExpress.ExpressApp.ConditionalAppearance.ApplyAppearanceEventArgs class as event arguments:
It is important to note that you can cast the Item property to the IViewElementProvider interface and then use its ViewElement property to access an underlying object for additional customizations.[C#]public class ApplyAppearanceEventArgs : HandledEventArgs { public ApplyAppearanceEventArgs(IAppearance appearance, AppearanceItemType itemType, string itemName, object item, object[] contextObjects); public IAppearance Appearance { get; } public object[] ContextObjects { get; } public object Item { get; } public string ItemName { get; } public AppearanceItemType ItemType { get; } }
The above events are very similar to the EditorStateCustomizing/CustomEditorStateCustomization and EditorStateCustomized events exposed in the ConditionalEditorState module (ConditionalEditorState - provide an event to allow additional user customization of target editors), and so they can be used for the same tasks - providing custom appearance customizations.
Let's demonstrate the use of the CustomApplyAppearance event with a small sample:
[C#]public class S30263 : ViewController<ListView> { protected override void OnActivated() { base.OnActivated(); Frame.GetController<AppearanceController>().CustomApplyAppearance += new EventHandler<ApplyAppearanceEventArgs>(S30263_AppearanceApplied); } protected override void OnDeactivated() { Frame.GetController<AppearanceController>().CustomApplyAppearance -= new EventHandler<ApplyAppearanceEventArgs>(S30263_AppearanceApplied); base.OnDeactivated(); } private void S30263_AppearanceApplied(object sender, ApplyAppearanceEventArgs e) { if (e.ItemType == AppearanceItemType.ViewItem.ToString() && e.ItemName == "TargetFormattingProperty" && e.ContextObjects.Length>0) { //Dennis: Use the code below to cancel appearance customizations for the selected records in the ListView. e.Handled = View.SelectedObjects.Contains(e.ContextObjects[0]); //Or //Dennis: Cast the e.Item property to the IViewElementProvider interface and then use its ViewElement property to access underlying object for additional customizations. //DevExpress.ExpressApp.Editors.IViewElementProvider provider = (DevExpress.ExpressApp.Editors.IViewElementProvider)e.Item; //DoSomethingInCaseOfXtraGrid(provider.ViewElement as DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs); } } }
Thanks,
Dennis
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.