New-ConsoleCollapsible
Creates a collapsible section for Show-ConsoleApp, or an accordion of sections that keeps one open.
Syntax
New-ConsoleCollapsible
[-Content <Object>]
[-Disabled]
[-Expanded]
[-Key] <String>
[[-Label] <String>]
[-OnChange <ScriptBlock>]
[-Summary <String>]
[-TabIndex <Int32>]
[-ValidationMessage <String>]
[<CommonParameters>]#SectionNew-ConsoleCollapsible
-Accordion
[-Content] <Object>
[<CommonParameters>]#AccordionDescription
A section is a focusable header row with its content below. Enter, Space, Left/Right and a click on the header fold and unfold it; while it is collapsed the header shows -Summary and the content's inputs leave the focus order. The final state holds whether each section is expanded. With -Accordion, -Content emits sections and opening one folds the others; + expands every section and - folds them all.
Examples
Example 1
Show-ConsoleApp -Content {
New-ConsoleCollapsible -Accordion -Content {
New-ConsoleCollapsible -Key Synopsis -Expanded -Content { 'Gets the services on a computer.' }
New-ConsoleCollapsible -Key Examples -Summary '(2)' -Content {
'Get-Service -Name win*'
'Get-Service | Where-Object Status -eq Running'
}
}
}Fold long sections of a help page and keep one open at a time.
Parameters
- -Content Object
- The section's widgets, text or a script block that emits them. With -Accordion, the sections of the group.
- -Disabled SwitchParameter
- Disables the header and removes it from keyboard focus traversal.
- -Expanded SwitchParameter
- Starts the section expanded.
- -Key String
- Unique key in the application's state; the value is whether the section is expanded.
- -Label String
- Header text; defaults to the key.
- -OnChange ScriptBlock
- Runs once each time the section folds or unfolds, on the owning input thread. Receives param($Value, $State) and injected $Value, $State and $Control. Output is discarded.
- -Summary String
- Muted text after the header while collapsed, such as a count.
- -TabIndex Int32
- Keyboard focus order. Equal values preserve layout declaration order.
- -ValidationMessage String
- Validation text shown in the header.
- -Accordion SwitchParameter
- Groups the sections emitted by -Content so that opening one folds the others.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.