There is no way for this to happen. A RadDockZone must have only RadDock controls as children. Custom controls have a different type and will, therefore throw an exception. The zone is tightly coupled with the dock to offer easy integration like drag-drop, state saving, etc., and this has its price.
Templated RadDock control inside of a RadDockZone?
-
02-04-2022 - |
Domanda
I've created a templated ASP.NET user control based on the RadDock control. However, when adding such a control to a RadDockZone causes a runtime error stating that it can only contain RadDock controls. Is there any way to solve this?
Templated user control markup
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TemplatedDock.ascx.cs" Inherits="TemplatedDock" %>
<telerik:RadDock ID="RadDock1" runat="server" EnableAnimation="True" DockHandle="Grip" Resizable="True">
<ContentTemplate>
<asp:PlaceHolder ID="dockPlaceholder" runat="server"></asp:PlaceHolder>
</ContentTemplate>
</telerik:RadDock>
Templated user control code-behind
public partial class TemplatedDock : System.Web.UI.UserControl
{
private ITemplate _content;
[TemplateContainer(typeof(ContentContainer))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TemplateInstance(TemplateInstance.Single)]
public ITemplate Content
{
get
{
return _content;
}
set
{
_content = value;
}
}
void Page_Init()
{
if (_content != null)
{
ContentContainer container = new ContentContainer();
_content.InstantiateIn(container);
dockPlaceholder.Controls.Add(container);
}
}
}
public class ContentContainer : Control, INamingContainer{}
}
Usage in RadDockZone
<telerik:RadDockZone ID="RadDockZone1" runat="server">
<a:TemplatedDock>
<Content>
<telerik:RadGrid ID="someGrid" runat="server"></telerik:RadGrid>
</Content>
</a:TemplatedDock>
</telerik:RadDockZone>
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow