Current filter:
                                You should refresh the page.
                                  • Can you guys add an option to collapse the layout groups that are used in xaf applications?

                                1 Solution

                                Creation Date Importance Sort by

                                Hi Charles,
                                Thanks for the suggestion. We will take it into account. For now, it's possible to implement this feature yourself:

                                With XAF v19.2, the new platform-agnostic options - IModelLayoutGroup.IsCollapsibleGroup and IModelLayoutGroup.IsGroupCollapsed - are available to control this behavior for both WinForms and ASP.NET apps. For more information on how it affects the former ASP.NET Application Model options, see this breaking change.

                                For older versions or custom-tailored implementations when the standard solution is not suitable, consider the options below.

                                v15.2 - v19.1
                                The new XAF web UI provides a built-in solution for this task. You can enable it for required layout groups in the Model Editor via the new IsCollapsibleCardGroup option at the Views | <DetailView> | Layout  level.

                                Prior to v15.2
                                To accomplish this task, you need to create a custom LayoutManager and custom LayoutItemTemplate, LayoutGroupTemplate or TabbedGroupTemplate templates as demonstrated in the FeatureCenter demo (%Public%\Documents\DevExpress Demos 1X.X\Components\eXpressApp Framework\FeatureCenter\CS\FeatureCenter.Module.Web\Layout). For instance, you can inherit from the existing WebLayoutManager class and override the CreateLayoutGroupTemplate method to return a custom template for layout groups. The original method returns a LayoutGroupTemplate instance that creates a simple HTML table for the group header and puts nested layout items just below it in the same container. You can create a LayoutGroupTemplate descendant and override the LayoutContentControls method to create a collapsible group with the help of a script or custom control. In the simplest case, it is possible to use our ASPxNavBar control our ASPxRoundPanel with its ShowCollapseButton = True.

                                Prior to v19.2
                                You can access the LayoutControl and set its LayoutControlGroup.ExpandXXX properties either in a ViewController or a custom WinLayoutManager descendant. To save and control the expandable state of required layout groups via the Model Editor, extend the IModelWinLayoutGroup interface with custom options as described in the eXpressApp Framework > Task-Based Help > How to: Extend the Application Model help topic. Handle the View.ModelSaved event to write the expanded state from the control to the Application Model. Refer to the Model.DesignedDiffs.xafml  and ExpandableLayoutGroupViewController.cs files under the WinForms module project in the  archive for more details:

                                using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Model; using DevExpress.ExpressApp.Win.Layout; using DevExpress.ExpressApp.Win.SystemModule; using DevExpress.Utils; using DevExpress.XtraLayout; namespace YourSolutionName.Module.Win.Controllers { public partial class ExpandableLayoutGroupViewController : ViewController<DetailView>, IModelExtender { Dictionary<string, IModelWinLayoutGroupExtender> itemToWinModelLayoutGroupExtenderMap = new Dictionary<string, IModelWinLayoutGroupExtender>(); WinLayoutManager winLayoutManager = null; protected override void OnActivated() { base.OnActivated(); winLayoutManager = View.LayoutManager as WinLayoutManager; if(winLayoutManager != null) { winLayoutManager.ItemCreated += ExpandableLayoutGroupViewControllercs_ItemCreated; if(winLayoutManager.Container != null) { winLayoutManager.Container.HandleCreated += Container_HandleCreated; } View.ModelSaved += View_ModelSaved; } } void Container_HandleCreated(object sender, EventArgs e) { LayoutControl lc = ((LayoutControl)sender); lc.BeginUpdate(); foreach(BaseLayoutItem item in lc.Items) { if((item is LayoutControlGroup) && itemToWinModelLayoutGroupExtenderMap.ContainsKey(item.Name)) { ((LayoutGroup)item).Expanded = itemToWinModelLayoutGroupExtenderMap[item.Name].Expanded; ((LayoutGroup)item).HeaderButtonsLocation = itemToWinModelLayoutGroupExtenderMap[item.Name].HeaderButtonsLocation; ((LayoutGroup)item).ExpandButtonVisible = true; ((LayoutGroup)item).ExpandOnDoubleClick = true; } } lc.EndUpdate(); } void ExpandableLayoutGroupViewControllercs_ItemCreated(object sender, ItemCreatedEventArgs e) { if(e.ModelLayoutElement is IModelWinLayoutGroup) { IModelWinLayoutGroupExtender modelLayoutGroupExtender = (IModelWinLayoutGroupExtender)e.ModelLayoutElement; if((modelLayoutGroupExtender).Expandable) { itemToWinModelLayoutGroupExtenderMap.Add(e.Item.Name, (IModelWinLayoutGroupExtender)e.ModelLayoutElement); } } } void View_ModelSaved(object sender, EventArgs e) { foreach(BaseLayoutItem item in winLayoutManager.Container.Items) { if((item is LayoutControlGroup) && itemToWinModelLayoutGroupExtenderMap.ContainsKey(item.Name)) { itemToWinModelLayoutGroupExtenderMap[item.Name].Expanded = ((LayoutGroup)item).Expanded; } } } protected override void OnDeactivated() { if(winLayoutManager != null) { winLayoutManager.ItemCreated -= ExpandableLayoutGroupViewControllercs_ItemCreated; if(winLayoutManager.Container != null) { winLayoutManager.Container.HandleCreated -= Container_HandleCreated; winLayoutManager = null; } View.ModelSaved -= View_ModelSaved; } itemToWinModelLayoutGroupExtenderMap.Clear(); base.OnDeactivated(); } public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { extenders.Add<IModelWinLayoutGroup, IModelWinLayoutGroupExtender>(); } } public interface IModelWinLayoutGroupExtender { [DefaultValue(true)] bool Expanded { get; set; } [DefaultValue(true)] bool Expandable { get; set; } [DefaultValue(GroupElementLocation.Default)] GroupElementLocation HeaderButtonsLocation { get; set; } } }
                                Show all comments
                                • Charles Kirby 08.16.2010

                                  I was able to display the expand button by using the steps in the other post. However, the changes are obviously not persisted with the default integral settings. I would still like to see this feature as an integral part of xaf at some point. Then developers could enable/disable the expand button from the model editor and at runtime, collapsed states of groups could automatically be persisted with the rest of the settings.

                                • Dennis (DevExpress Support) 02.24.2016

                                  Starting with v15.2, the new XAF web UI provides a built-in solution for this task. You can enable it for required layout groups in the Model Editor via the new IsCollapsibleCardGroup option at the Views | <DetailView> | Layout  level. I have provided screenshots and more info on this in my blog at

                                • Pawel Botwina 02.24.2016


                                  I have tested this functionality. Currently it lacks ability to set initial state (collapsed or not collapsed) and group caption should be clickable.

                                • Dennis (DevExpress Support) 02.24.2016

                                  Thanks for your comments, Pawel!

                                • Dennis (DevExpress Support) 06.27.2019


                                  We are supporting this functionality out-of-the-box in XAF WinForms v19.2.

                                  Question 1: How likely is it your collapsible layout group would contain other collapsible layout groups?
                                  Consider two implementation options:
                                  1.1. A collapsible group may contain other collapsible groups.

                                  1.2. A collapsible group may not contain other collapsible groups. It works like on the Web with its IsCardGroup property, but there are no technical limitations for this in WinForms.

                                  Question 2: How often did you touch the related Web API (IsCollapsibleCardGroupIsCardGroupIsCardGroupCollapsed) or are you ready for a breaking change in this regard?
                                  We aim to make the IsCollapsile and IsCollapsed options configurable from a cross-platform module - this is one of our main product qualities. Based on our research, customers touched the APIs above in rare advanced cases - the majority configures it in the Model Editor. With the the automatic Model Differences conversion feature, we expect that only a few our users will be affected in v19.2.

                                • Genesis Supsup (QuickZ) 06.27.2019

                                  When there are too many collapsible groups and with lots of nested collapsible groups in them, I think you should provide a hierarchical navigation panel to invoke or bring-to-front/visibility a selected group then auto-expand it.

                                • Dennis (DevExpress Support) 06.28.2019

                                  @Genesis Supsup (QuickZ): Thank you for your feedback. As far as I understand, you are asking about a new feature like this: This is not something we planned as part of this WinForms enhancement, but our team will take it into account.

                                • Dennis (DevExpress Support) 07.15.2019

                                  With XAF v19.2, the new platform-agnostic options - IModelLayoutGroup.IsCollapsibleGroup and IModelLayoutGroup.IsGroupCollapsed - are available to control this behavior for both WinForms and ASP.NET apps. For more information on how it affects the former ASP.NET Application Model options, see this breaking change.

                                • Chris Royle (LOB) 07.15.2019

                                  Just a general observation - we've rolled our own in the past. Using this is a great way of hiding detail - unfortunately it also obscures information - so we've avoided using it too often.

                                  I think what would make this functionality more useful is to have a bindable/data driven caption for when the group is collapsed - e.g. if one has an address group then when this is collapsed the group caption would display a concatenated address.

                                  A simple asterisk could be used to draw a users attention to a collapsed group which contains populated information for example.

                                • Dennis (DevExpress Support) 07.16.2019

                                  Thank you for sharing, Chris. As far as I understand, this is something like ObjectPropertyEditor (Address), but in the header.

                                • Mikunda Petr 07.16.2019

                                  Hi guys,
                                  Thats great this functionality is implemented.
                                  Is there possibility add conditional collapsing? Something like TargetObjectCriteria for group? If Criteria Fits Expand otherwise Collapse
                                  Simple use case:
                                  User has big DetaiView and it is not desired to expand groups where no records are presented
                                  Typically Description, ListViews, Address etc. maybe take this into account and do not expand empty groups of data optionally or conditionally

                                  One more thing is like Chris told some kind of customizable Title of group - we typically hide ListView to group so we show name and number of records in ListView - Only when Group contains single ListView. -> Of course we use such functionality in Non XAF App I just use terminology related to XAF (ListView, Group, etc)

                                  It would be great implement such functionality!!! :)

                                • Dom Sinclair 07.16.2019

                                  Hi Dennis

                                  It's nice to see this implementation on it's way, and there are unquestionably occasions when such functionality is very useful and welcome.  As with all things though it comes with a price, and as Chris rightly points out if the collapsed section does actually contain information then unless there is some indication to that effect the end user will as often as not ignore opening it up.

                                  I have in the past tried both collapsible regions and tabs, both work but only if the end user can be bothered to make them work.  As a developer I value the additional space collapsible regions can provide.  When I swap my development hat for my support hat I often find myself regretting the decision my developer self took to implement them.

                                  Anything that could be done to indicate that a collapsed region contained a field or fields that were populated with data would be a distinct advantage.

                                • Chris Royle (LOB) 07.16.2019

                                  Hi @Dennis

                                  Ideally the caption could be data driven - i.e. bindable to a calculated field value. This would be most flexible.

                                  But referring back to your comment, yes.... the Address group would show ADDRESS with the component fields in the group. When collapsed it might show ADDRESS: 4770 Transit Road, Ottawa Canada. or ADDRESS: (none)

                                  You might also have a data group of phone numbers, where one is the default.

                                  Sometimes a count would be useful e.g. a Contacts Group collapsed might read CONTACTS (None) or CONTACTS (1 Lead).

                                  If a user doesn't know that the group is 'hiding' data. they have to open/close groups and actively look for data.


                                • Dennis (DevExpress Support) 07.16.2019

                                  Thank you for your suggestions, Guys. We received a few related requests where users wanted to 1) provide a different caption by a condition (appearance rules for captions); 2) display the count of records for layout tabs or groups containing ListView; 3) provide other additional information in layout tabs or group headers. While they all look reasonable, in all these cases it is also important to consider how separate SQL queries to evaluate criteria for each layout element will affect the form loading performance.

                                  While we do not have a sufficient number of scenarios to think of generic solutions at this stage, we will surely take your suggestions into account. All these tasks are feasible in the current version with custom code (see the controller above for more inspiration). If you already implemented these customizations and tested them with your end-users, please share your code and screenshots in comments for the benefit of XAF community. Thank you once again!

                                  While testing this feature in WinForms, as an end-user I wanted the capability to mark layout groups as "collapsible" at runtime. For now, only developers or power users can configure the IsCollapsibleGroup option for layout nodes in the Model Editor. I thought about extending the сontext menu that appears in customization mode, but wanted to check it with you first.
                                  What do you think?