- 11 Jan 2022
- 4 Minutes to read
Horizontal and Vertical Stacks
- Updated on 11 Jan 2022
- 4 Minutes to read
The Horizontal and Vertical Stack Layouts dynamically resize its and its child controls within upon expanding/shrinking a child control. Each added control automatically resizes to the height of the workspace; however, the width measurement of a child control can be manually adjusted.
A recommended best practice involves populating a Stack Layout with a Grid Layout and then to populate the Grid with the desired controls. With the nested Grid Layout, its columns and rows help uniformly organize controls. Remember to rename the Stack, Grid, and any child controls for best organization practices.
A limitation of Stacks Layouts; however, is that it cannot dynamically resize the Form: stacks will not grow or shrink the whole Form's size.
This document will demonstrate how to use the Horizontal Stack Layout, but similar configurations are applicable to the Vertical Stack Layout.
Besides naming the Stack, the Children Size Mode setting determines how its child controls are sized within the Stack. By default, this is set to Scroll.
|Children Size Mode Option||Description|
|Scroll||Allows total size of child controls to extend beyond that of the Stack's dimensions by including a horizontal/vertical scrollbar to navigate|
|ExpandChildrenThenScroll||Allows child controls to expand increasing their size in the Stack. This can also extend beyond the Stack's dimensions thus supports a scrollbar.|
|FitChildren||Allows child controls to resize according to the size of Stack. Since this setting is constrained by the Stack's dimensions, no scrollbar is supported.|
The following example creates an Order Form for a customer to complete. If the billing address is the same as the shipping address, the billing address fields will hide. Otherwise, the billing address fields appear and expand vertically on the Form moving the other Form controls down.
- In a Designer Folder, create a Flow.
- In the Flow Designer, navigate to the Steps > Favorite Steps section and add a Show Form step to the workspace. Connect it to the Start step.
- With the Show Form step selected, select Pick or Create Form from the Properties panel.
- In the Create or Pick window, under Create New > Name, enter Customer Information Form. Click CREATE to enter the Form Designer.
- In the Form Designer, navigate to the Form Controls > Layouts section and drag a Vertical Stack control to the Form. This is required for space reclamation within the Stack.
- Resize the Vertical Stack control so that it takes up most of the space on the Form.
- From the Steps > Layouts section, drag and drop a Grid control to the Vertical Stack control.
- Name the Grid under Common Properties > Name.
- Configure the Grid to have two resizable Columns at 0.15 and 1.
- Configure the Grid to have two resizable Rows at 1.
- Right-click the new Grid control and Copy it.
- Add a new Grid control to the Vertical Stack control. Name the Grid.
- Paste the Grid copied to the clipboard into the clear Grid. Name this Grid.
- From the Steps > Favorite Controls section, drag and drop a Button [Done] to the Grid controls below the Vertical Stack.For this function to work properly, each control must be placed in a separate Grid. For reference, the Vertical Stack control contains four Grids: the Top Grid, the Bottom Grid Holder where the Bottom Grid lives, and the Button Grid.
- From the Form Controls > Data category, drag and drop a Checkbox control to the top-left of the Grid field. Expand the control to fill the first row of the top Grid.
- Add the text Shipping Address Same as Billing? as the Text and Data Name under Common Properties.
- With the Checkbox selected, navigate to the Properties panel > Data and enable the Is Checked Boolean. This will show the fields only if the shipping address is not the same.
- Next, select the bottom Grid component within the additional Grid and navigate to the Properties panel > Grid Setup > Rows, and add two additional resizable Rows at 1.
- From the Form Controls > Favorite Controls section, add four Label controls (Address, City, State, Zip Code) and four corresponding Text Boxes.
- Drag the Grid containing the Button [Done] to the Vertical Stack controls.
- Next, navigate to the Properties panel > Form Rules > Visibility Rules of the entire Form. Select Add New.
- In the Add Visibility Rules window, name the Rule [Bottom Grid Visibility Rule].
- Under Rule Data > Rule, select Create.
- In the Create New Rule window, name the Rule [Visibility Rule].
- Click CREATE to enter the Rule Designer.
- In the Rule Designer, select SETUP INPUT DATA.
- In the Data Definitions window, name the input Show Field and select the type Boolean [Logical]. Click CLOSE.
- In the If portion of the Rule statement, choose the Show Field input from the Select Data Element drop down list.
- Select Is False from the Logic Rules section of the Pick Verb drop down list. The Rule evaluates if checkbox Boolean is enabled which it will be by default. Therefore, the Rule evaluate true until the Boolean is unchecked aka false. The shipping information fields will appear on the Form. For more information regarding Visibility Rules, please navigate to the Controlling Form Fields with Visibility Rules article.
- Save and Close the Rule Designer.
- In the Add Visibility Rules window, select Update Inputs.
- Navigate to Triggers and enable the Shipping Address Same as Billing? [Checkbox]: Value Changed boolean.
- Navigate to Apply to Controls and enable the Bottom Grid Holder.
- Select the pencil icon next to Show Field [Boolean].
- In the Edit Rule Inputs window, change the Input Data > Input Type to Form Component.
- From the Form Data Name drop down list, select Shipping Address Same as Billing?.
- Click OK in both windows.
- Save and Close the Form Designer.
- In the Flow Designer, connect the Done outcome of the Show Form step to the End step.
- With the Show Form step selected, navigate to the Properties panel > Inputs and change each input to an Ignore input mapping type.
- Select Debug from the Top Action Panel, this will automatically save the Flow.
- Notice by default the Form fields are hidden. Disable the boolean.
- Notice the Form fields appear when the boolean is unchecked.