# How to use it

## Create Views

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

{% code title="Opening-Event" %}

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

{% endcode %}

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

{% code title="ValueChanged-Event" %}

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

{% endcode %}

## Create Stack

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

{% hint style="info" %}
Optional if you have set the **AutoSetup** designtime-only property to `False`.
{% endhint %}

* Insert `Opening`-Event Handler (Insert > Event-Handler...) and initialize MyStackView:

{% code title="Opening-Event" %}

```xojo
If Not Self.AutoSetup Then
  // do this for each View you droped into MyStackView
  Views.Add(MyView1)
  Views.Add(MyOtherView1)
End If
```

{% endcode %}

## Create Scroll Container

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

{% hint style="info" %}
Optional if you have set the **AutoSetup** designtime-only property to `False`.
{% endhint %}

* Insert `Opening`-Event Handler (Insert > Event Handler...) and initialize MyScrollView:

{% code title="Opening-Event" %}

```xojo
If Not Self.AutoSetup Then
  Init(MyStackView1)
End If
```

{% endcode %}

## Use it within your App

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xojo.gitbook.io/add-ons/stackview/version-3/how-to.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
