VariableSizedWrapGrid is not as versatile as Grid, but it can do one trick that Grid cannot: wrap its elements when there’s not enough space. Although its name ends in “Grid,” VariableSizedWrapGrid is more like a StackPanel than a Grid. It stacks its children vertically (by default) or horizontally based on its Orientation property, and it doesn’t define any attached properties for placing items in specific rows or columns. The stack simply wraps into new rows/columns as needed.

Figure 4.6 demonstrates how the following VariableSizedWrapGrid placed directly in a Page handles various layout conditions that can be inflicted by a user. It contains 10 buttons that differ only by Background and Content:

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.