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 BasicPublic 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 BasicPublic 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 BasicPublic 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 BasicPublic 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