githubEdit

Bottom-to-Top Stacking

Introduction

By default a ScrollViewer stacks its top-to-bottom. We can modify stack panel to support bottom-up stacking, such as if used for a chat display or console-style output.

Creating the Layout

The ScrollViewer's inner pane, obtained through the name "InnerPanelInstance" stacks its children top-to-bottom by default. Furthermore, then panel expands in response to its children.

The following visualization shows the size of a panel as children are added with a red rectangle:

Red rectangle shows the size of the inner panel

We want to make the following modifications to our panel:

  1. If the inner panel is smaller than the entire ScrollViewer, then the inner panel should fill the entire ScrollViewer vertically

  2. All children in the inner panel should be bottom-aligned rather than top-aligned

We will follow a similar pattern to the Bottom-Up Stack example. Specifically we will create another panel that we can place inside the inner panel, and this bottom-up panel will be docked to the bottom.

The following code shows how to achieve this:

Labels added to a bottom-up stack

Last updated

Was this helpful?