Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Content Panel

Siticone Content Panel

The SiticoneContentPanel is an advanced container designed to act as the main viewport for your application. It automatically pairs with a SiticoneNavbar to handle view switching, title management, and navigation history without writing boilerplate code.

Integration & Navbar

The core functionality relies on connecting this panel to a Navbar control. Once connected, it listens for navigation changes automatically.

Property Type Description & Usage Example
TargetNavbar SiticoneNavbar contentPanel.TargetNavbar = siticoneNavbar1; The essential link. Setting this property automatically subscribes the content panel to the navbar's selection events.
AutoCreateViews bool contentPanel.AutoCreateViews = true; If true, clicking a navbar item that hasn't been defined yet will automatically generate a blank view with a title.
AutoManageContent bool contentPanel.AutoManageContent = true; Determines if the panel automatically clears old content and loads new content on navigation. Set to false if you want to handle content switching manually.
TrackHistory bool contentPanel.TrackHistory = true; Enables an internal stack to track navigation history, allowing for "Back" button functionality.

Sections & Appearance

The panel is divided into a Title Section (top) and a Content Section (fill).

Property Type Description & Usage Example
ShowTitle bool contentPanel.ShowTitle = true;
TitleHeight int contentPanel.TitleHeight = 60; Height of the top title bar area in pixels.
TitleBackColor Color contentPanel.TitleBackColor = Color.White;
ContentBackColor Color contentPanel.ContentBackColor = Color.WhiteSmoke;
ShowTitleSeparator bool contentPanel.ShowTitleSeparator = true; Draws a thin line between the title and content areas.
TitleSeparatorColor Color contentPanel.TitleSeparatorColor = Color.LightGray;
DefaultTitleFont Font contentPanel.DefaultTitleFont = new Font("Segoe UI", 12f); Font used when auto-generating view titles.

Empty State Handling

Visual feedback when a view has been created but contains no controls.

Property Type Description & Usage Example
ShowEmptyContentMessage bool contentPanel.ShowEmptyContentMessage = true;
EmptyContentMessage string contentPanel.EmptyContentMessage = "No content loaded."; Text displayed in the center of the panel when no child controls are detected.
ConsiderBackColorAsContent bool contentPanel.ConsiderBackColorAsContent = true; If true, a panel with a non-default background color is considered "content" even if it has no children.

Public Methods

Methods to manually control navigation, inject content, and manage state.

NavigateToView(string viewName)
// Manually navigates to a specific view by name.
// This triggers the same logic as clicking a navbar item.
contentPanel.NavigateToView("Dashboard");
RegisterView(string, Control, Control)
// Defines a specific layout for a view name.
// viewName: Matches the Navbar item text.
// titleControl: A custom panel/label for the top section.
// contentControl: The main user control or panel for the body.
contentPanel.RegisterView("Settings", myTitlePanel, mySettingsUserControl);
AddContentToView(string, Control)
// Injects a control into an existing view's content area.
// Useful for dynamically building views at runtime.
contentPanel.AddContentToView("Reports", new ReportGridControl());
NavigateBack()
// Navigates to the previous view in the internal history stack.
// Returns true if navigation was successful, false if history is empty.
if (contentPanel.NavigateBack()) {
                Console.WriteLine("Went back successfully");
}

Events

Hooks to intercept or respond to navigation lifecycles.

Event Description
BeforeNavigate Fires before the view changes. Includes NavigationEventArgs. Set e.Cancel = true to prevent navigation (e.g., if there are unsaved changes).
AfterNavigate Fires immediately after the view has successfully changed.
ViewCreating Fires when the panel creates a view for the first time. Allows you to inject custom controls before display.
ViewCreated Fires after the view panel and its containers have been initialized.

Detailed Usage Examples

Example 1: Basic Setup

The simplest way to use the control: Connect it to a Navbar and let it auto-create views.

C# - Initialization
public MainForm()
{
                InitializeComponent();

                // Link the Navbar to the ContentPanel
                // Assuming siticoneNavbar1 has items: "Home", "Users", "Settings"
    siticoneContentPanel1.TargetNavbar = siticoneNavbar1;
    
                // Optional: Styling
    siticoneContentPanel1.TitleBackColor = Color.White;
    siticoneContentPanel1.ContentBackColor = Color.FromArgb(245, 247, 250);
}

Example 2: Manual View Registration

Using RegisterView to assign specific UserControls to specific Navbar items.

C# - Custom Views
private void SetupViews()
{
                // Create your UserControls
                var dashboardView = new DashboardUserControl { Dock = DockStyle.Fill };
                var settingsView = new SettingsUserControl { Dock = DockStyle.Fill };

                // Create custom title headers (optional)
                var dashTitle = new Label 
    { 
        Text = "Main Dashboard", 
        Font = new Font("Segoe UI", 14, FontStyle.Bold),
        TextAlign = ContentAlignment.MiddleLeft,
        Dock = DockStyle.Fill
    };

                // Register them to the ContentPanel
                // "Dashboard" and "Settings" must match the text on your Navbar buttons
    siticoneContentPanel1.RegisterView("Dashboard", dashTitle, dashboardView);
    
                // Registering with default title behavior (passing null for title)
    siticoneContentPanel1.RegisterView("Settings", null, settingsView);
}

Example 3: Handling Navigation History

Implementing a "Back" button functionality using the internal history stack.

C# - Navigation History
private void btnBack_Click(object sender, EventArgs e)
{
                // Attempt to go back
                bool success = siticoneContentPanel1.NavigateBack();
    
                if (!success)
    {
                MessageBox.Show("No previous views in history.");
    }
}

// Update Back Button availability
private void siticoneContentPanel1_AfterNavigate(object sender, NavigationEventArgs e)
{
                // Check if there are items in the history stack
    btnBack.Enabled = siticoneContentPanel1.NavigationHistory.Count > 0;
}

Example 4: Persistence (Import/Export)

Saving the view configuration to XML allows you to restore state or layouts.

C# - Save/Load Config
private void SaveLayout()
{
                // Exports settings, colors, and current navigation state
    siticoneContentPanel1.ExportConfiguration("app_layout.xml");
}

private void LoadLayout()
{
                if (File.Exists("app_layout.xml"))
    {
        siticoneContentPanel1.ImportConfiguration("app_layout.xml");
    }
}