#1,054 – TabPanel Wraps and Evenly Spaces

Recall that a WrapPanel stacks controls horizontally until it fills the available space and then wraps to a new line.  (Or stacks vertically and wraps to a new column, if the orientation is vertical).

1054-001

The TabPanel, normally used to display the tabs in a TabControl, behaves a little like the WrapPanel.  But when it decides to wrap to a new line, it evenly spaces the items within each line.

We can demonstrate this by starting with a wide window and then narrowing it to cause the items to wrap.

1054-002

1054-003

1054-004

We can better visualize what’s going on here by changing the HorizontalAlignment of the Labels to Center so that they don’t stretch to fill the available space.  We can then see the gaps introduced between elements by the TabPanel.

1054-005

1054-006

1054-007

1054-008

Notice that the TabPanel also attempts to place roughly the same number of items on each row.

Advertisements