KB Article T502298
Visible to All Users

Web Layout Manager improvements and important changes in XAF v17.1

In the 17.1 version, we have improved the scenario of loading ASPxPageControl tab content when WebLayoutManager.DelayedItemsInitialization equals true and the Conditional Appearance module is involved:
ConditionalAppearance - How to avoid not fully initialized layout tab content when using Appearance rules with ViewItemVisibility.Hide on the Web. There are also several breaking changes in the initialization and usage of LayoutItemTemplateContainerBase descendants.

- If custom templates are used for laying out controls (only LayoutGroupTemplate and TabbedGroupTemplate descendants), it is necessary to call the LayoutItemTemplateContainerBase.Instantiate()  method before adding LayoutItemTemplateContainerBase descendants if WebLayoutManager.DelayedItemsInitialization equals true. For example:

C#
public class CustomLayoutGroupTemplate : LayoutGroupTemplate {     protected override void LayoutContentControls(LayoutGroupTemplateContainer layoutGroupTemplateContainer, IList<Control> controlsToLayout) {         foreach(Control control in controlsToLayout) {             LayoutItemTemplateContainerBase templateContainer = control as LayoutItemTemplateContainerBase;             if(templateContainer != null && templateContainer.LayoutManager.DelayedItemsInitialization) {                 templateContainer.Instantiate();             }             layoutGroupTemplateContainer.Controls.Add(control);         }     } }
Visual Basic
Public Class CustomLayoutGroupTemplate Inherits LayoutGroupTemplate Protected Overrides Sub LayoutContentControls(layoutGroupTemplateContainer As LayoutGroupTemplateContainer, controlsToLayout As IList(Of Control)) For Each control As Control In controlsToLayout Dim templateContainer As LayoutItemTemplateContainerBase = TryCast(control, LayoutItemTemplateContainerBase) If templateContainer IsNot Nothing AndAlso templateContainer.LayoutManager.DelayedItemsInitialization Then templateContainer.Instantiate() End If layoutGroupTemplateContainer.Controls.Add(control) Next End Sub End Class

- If a LayoutItemTemplateContainer is created in the WebLayoutManager descendant, then it is necessary to set the LayoutItemTemplateContainer.ViewItem and LayoutItemTemplateContainer.Template properties. For example:

C#
public class CustomWebLayoutManager : WebLayoutManager {     protected override LayoutItemTemplateContainer LayoutItem(ViewItemsCollection viewItems, IModelLayoutViewItem layoutItemModel) {         LayoutItemTemplateContainer templateContainer = new LayoutItemTemplateContainer(this, viewItems, layoutItemModel);         templateContainer.ViewItem = viewItems[layoutItemModel.ViewItem.Id];         templateContainer.Template = LayoutItemTemplate;         ...         return templateContainer;     } }
Visual Basic
Public Class CustomWebLayoutManager Inherits WebLayoutManager Protected Overrides Function LayoutItem(viewItems As ViewItemsCollection, layoutItemModel As IModelLayoutViewItem) As LayoutItemTemplateContainer Dim templateContainer As New LayoutItemTemplateContainer(Me, viewItems, layoutItemModel) templateContainer.ViewItem = viewItems(layoutItemModel.ViewItem.Id) templateContainer.Template = LayoutItemTemplate ... Return templateContainer End Function End Class

- If a LayoutGroupTemplateContainer is created in the WebLayoutManager descendant, then it is necessary to set the LayoutGroupTemplateContainer.Template property. For example:

C#
public class CustomWebLayoutManager : WebLayoutManager {     protected override LayoutGroupTemplateContainer ProcessStandardGroup(ViewItemsCollection viewItems, IModelLayoutGroup layoutGroupModel) {         ImageInfo headerImageInfo = ImageLoader.Instance.GetImageInfo(layoutGroupModel.ImageName);         LayoutGroupTemplateContainer templateContainer = new LayoutGroupTemplateContainer(this, viewItems, layoutGroupModel, headerImageInfo);         templateContainer.Template = LayoutGroupTemplate;         ...         return templateContainer;     } }
Visual Basic
Public Class CustomWebLayoutManager Inherits WebLayoutManager Protected Overrides Function ProcessStandardGroup(viewItems As ViewItemsCollection, layoutGroupModel As IModelLayoutGroup) As LayoutGroupTemplateContainer Dim headerImageInfo As ImageInfo = ImageLoader.Instance.GetImageInfo(layoutGroupModel.ImageName) Dim templateContainer As New LayoutGroupTemplateContainer(Me, viewItems, layoutGroupModel, headerImageInfo) templateContainer.Template = LayoutGroupTemplate ... Return templateContainer End Function End Class

- If a TabbedGroupTemplateContainer is created in the WebLayoutManager descendant, then it is necessary to set the TabbedGroupTemplateContainer.Template property. For example:

C#
public class CustomWebLayoutManager : WebLayoutManager {     protected override TabbedGroupTemplateContainer ProcessTabbedGroup(ViewItemsCollection viewItems, IModelTabbedGroup layoutGroupModel) {         TabbedGroupTemplateContainer templateContainer = new TabbedGroupTemplateContainer(this, viewItems, layoutGroupModel);         templateContainer.Template = TabbedGroupTemplate;         ...         return templateContainer;     } }
Visual Basic
Public Class CustomWebLayoutManager Inherits WebLayoutManager Protected Overrides Function ProcessTabbedGroup(viewItems As ViewItemsCollection, layoutGroupModel As IModelTabbedGroup) As TabbedGroupTemplateContainer Dim templateContainer As New TabbedGroupTemplateContainer(Me, viewItems, layoutGroupModel) templateContainer.Template = TabbedGroupTemplate ... Return templateContainer End Function End Class

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.