> For the complete documentation index, see [llms.txt](https://xojo.gitbook.io/add-ons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xojo.gitbook.io/add-ons/stackview/version-2/how-to.md).

# How to use it

## Create Views

* Add a Container Control to your Contents (Insert > Container Control)
* Set Name to **MyView** and Super to [ViewController](/add-ons/stackview/version-2/details/viewcontroller.md)
* Insert `Open`-Event Handler (Insert > Event Handler...) and initialize MyView:&#x20;

```xojo
// 50  = collapsed Height
// 250 = expanded Height
Init(50, 250)
```

* Drag and Drop some Controls you want to MyView
* Drag and Drop a DisclosureTriangle and add this Code to his `Action`-Event:

```xojo
Expand(Not Expanded)
```

## Create Stack

* Add a Container Control to your Contents (Insert > Container Control)
* Set Name to **MyStackView** and Super to [StackController](/add-ons/stackview/version-2/details/stackcontroller.md)
* Drag and Drop all **Views** (you created in step before) into MyStackView
* Insert `Open`-Event Handler (Insert > Event-Handler...) and initialize MyStackView:

```xojo
// do this for each View you droped into MyStackView
Views.Add(MyView1)
Views.Add(MyOtherView1)
```

## Create Scroll Container

* Add a Container Control to your Contents (Insert > Container Control)
* Set Name to **MyScrollView**
* Set Super to [ScrollController](/add-ons/stackview/version-2/details/scrollcontroller.md)
* Drag and Drop a ScrollBar into MyScrollView
* Drag and Drop **MyStackView** into **MyScrollView** (you don't need to set the position for your controls)
* Insert `Open`-Event Handler (Insert > Event Handler...) and initialize MyScrollView:

```xojo
Var nsScroller As Boolean

#If TargetMacOS Then
  // Or within a native NSScrollView (macOS-only)
  nsScroller = True
#Else
  // With regular Xojo ScrollBar (macOS, Linux, Windows)
  nsScroller = False
#Endif

Init(MyStackView1, ScrollBar1, True, nsScroller)
```

## Use it within your App

1. Drag and Drop MyScrollView into your Window
2. Press Run or Compile
3. Finished
