How to expand/collapse all panels in the diagram programatically?

Could you provide a simplified template and examples of expanded and collapsed panels?

I assume you have seen the definition and uses of the “PanelExpanderButton”. GoJS Buttons -- Northwoods Software