Old school XAML had a WrapPanel, but UWP doesn't. HTML supports this natively (if items don't fit on the current line, they simply wrap to the next line).
UWP XAML has "WrapGrid" and "VariableSizedWrapGrid", but these don't allow truly variable sized items, despite their name. They both take a dependency on the first item's width. The VariableSizedWrapGrid allows different sizes, but the sizes have to be a factor of the original item's size.
I believe their implementation is correct except for one issue, I think if you change the Orientation property after it has displayed, the layout won't update? They need to call InvalidateMeasure when the Orientation property is changed? Like the following...
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation",
typeof(Orientation), typeof(MyWrapPanel), new PropertyMetadata(Orientation.Horizontal, OnMeasureAffectingPropertyChanged));
private static void OnMeasureAffectingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
(sender as MyWrapPanel).OnMeasureAffectingPropertyChanged(e);
}
private void OnMeasureAffectingPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.InvalidateMeasure();
}