Search
AccordionItem Class
Remarks See Also
 





Represents an item in an Accordion control.

Namespace: MindFusion.Common.WinForms
Assembly: MindFusion.Common.WinForms

 Syntax

C#  Copy Code

public class AccordionItem : UserControl

Visual Basic  Copy Code

Public Class AccordionItem
    Inherits UserControl

 Remarks

The AccordionItem represents a single collapsible section within an Accordion control. It is a custom UserControl composed of a clickable header panel (which displays a title, an optional icon, and an expansion arrow on the right side) and a content panel that can be shown or hidden.

Setting Content

The content of an accordion pane can be any standard Windows Forms Control (including container controls like Panel, UserControl, or scrollable containers.

To set the content of a pane, add your control to the collection returned by the ContentPanel property:

C#  Copy Code

var utilityPane = new AccordionItem { Title = "System Tools" };
utilityPane.ContentPanel.Controls.Add(new MySystemToolsControl());

If the user interface needs to be updated dynamically, you can clear and replace child controls inside ContentPanel at runtime.

Sizing and Layout

The AccordionItem supports dynamic layout recalculations to ensure that it only occupies the necessary vertical space:

  • Explicit Sizing: If a specific pixel height is needed for the content, you can set the ContentHeight property.
  • Automatic Sizing (Default): When ContentHeight is set to null (the default), the pane automatically queries the first control inside its ContentPanel using its standard GetPreferredSize method to determine its expanded height. If the hosted control’s layout or content changes dynamically, calling UpdateContentSize on the AccordionItem will trigger a layout recalculation and resize the pane.

Properties

  • Appearance: The visual identity of the pane's header is controlled via the Title and Icon properties.
  • Expansion State: The IsExpanded property controls whether the content area is visible. Modifying this state automatically toggles the visibility of the ContentPanel, updates the direction of the arrow indicator in the header, and triggers a layout recalculation in the parent Accordion. When expanded, the pane resizes to fit its content; when collapsed, its height is strictly limited to the height of its header.

 Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            System.Windows.Forms.Control
                System.Windows.Forms.ScrollableControl
                    System.Windows.Forms.ContainerControl
                        System.Windows.Forms.UserControl
                            MindFusion.Common.WinForms.AccordionItem

 See Also