void OnTemplateSlot( INode element, string slotName, Panel panel )

book_4_sparkGenerated
code_blocksInput

Description

The OnTemplateSlot method is a virtual method in the SplitContainer class, which is part of the Sandbox.UI namespace. This method is responsible for handling template slots within the UI framework. It is typically used to associate a specific HTML element with a named slot in a UI panel, allowing for dynamic content placement and customization.

Usage

To use the OnTemplateSlot method, you need to override it in a derived class of SplitContainer. This method takes three parameters:

  • element: An instance of Sandbox.Html.INode representing the HTML element to be associated with the slot.
  • slotName: A string representing the name of the slot where the element should be placed.
  • panel: An instance of Sandbox.UI.Panel where the element will be added.

Override this method to customize how elements are assigned to slots in your UI components.

Example

public class CustomSplitContainer : SplitContainer
{
    protected override void OnTemplateSlot(Sandbox.Html.INode element, string slotName, Panel panel)
    {
        // Custom logic to handle template slots
        if (slotName == "custom-slot")
        {
            // Add the element to the specified panel
            panel.AddChild(element);
        }
        else
        {
            // Call base method for default behavior
            base.OnTemplateSlot(element, slotName, panel);
        }
    }
}