Hello DevExpress,
I used an ActionContainerViewItem to place an action in a detail view (see attached picture).
I would like to use the 32x32 image for the button and set the font size as bold for the button caption.
Any easy way to accomplish this ?
Many Thanks,
Julien
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Julien,
Thank you for contacting us. Presently, you can customize the required ActionContainerViewItem with the help of a controller:
using System; using System.Drawing; using DevExpress.ExpressApp; using DevExpress.XtraEditors; using DevExpress.ExpressApp.Utils; using FeatureCenter.Module.Actions; using DevExpress.ExpressApp.Editors; using DevExpress.ExpressApp.Win.Editors; using DevExpress.ExpressApp.Win.Templates.ActionContainers; namespace FeatureCenter.Module.Win { public class CustomizeWinActionContainerViewItemController : ViewController<DetailView> { public CustomizeWinActionContainerViewItemController() { TargetObjectType = typeof(DetailViewActionsObject); } protected override void OnActivated() { base.OnActivated(); foreach (WinActionContainerViewItem item in View.GetItems<WinActionContainerViewItem>()) { if (item.Id == "DetailViewActions") item.ControlCreated += item_ControlCreated; } } private void item_ControlCreated(object sender, EventArgs e) { ((ButtonsContainer)((ViewItem)(sender)).Control).ActionItemAdding += CustomizeWinActionContainerViewItemController_ActionItemAdding; } void CustomizeWinActionContainerViewItemController_ActionItemAdding(object sender, ActionItemEventArgs e) { if (e.Item.Action.Id == "SimpleAction") { SimpleButton button = (((ButtonsContainersSimpleActionItem)e.Item).Control) as SimpleButton; if (button != null) { if (!string.IsNullOrEmpty(e.Item.Action.Model.ImageName)) button.Image = ImageLoader.Instance.GetLargeImageInfo(e.Item.Action.Model.ImageName).Image; button.Font = new Font(button.Font, FontStyle.Bold); } } } } }
I tested this example code with the FeatureCenter demo. You will probably have to additionally modify it (e.g. adjust the item's height, etc.) to meet your exact business requirements.
Please let us know if you need any further assistance.
Thanks,
Dennis
Hello Dennis,
I decided to extend the model so it's easier to customize such actions.
public interface IGrandesIcôneActionContainerViewItemExtender { bool GrandesIcône { get; set; } } public sealed partial class WilLowXaf : ModuleBase { public WilLowXaf() { InitializeComponent(); } public override void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { base.ExtendModelInterfaces(extenders); extenders.Add<IModelActionContainerViewItem, IGrandesIcôneActionContainerViewItemExtender>(); } }
How do I access the GrandesIcône property of the ActionContainerViewItem in the CustomizeWinActionContainerViewItemController_ActionItemAdding method ?
many thanks in advance,
Julien
Hello Julien,
I see you want to perform customizations only if your custom model property is set true for the current View Item. In this scenario, it is better to check if the GrandesIcône is true before subscribing the ControlCreated event:
protected override void OnActivated() { base.OnActivated(); foreach (WinActionContainerViewItem item in View.GetItems<WinActionContainerViewItem>()) { if (((IGrandesIcôneActionContainerViewItemExtender)(item.Model)).GrandesIcône) item.ControlCreated += item_ControlCreated; } }
Thanks,
Konstantin B