public static void SetOrientation(this VirtualizingLayout layout, ScrollOrientation scrollOrientation)
 {
     // Note:
     // The public properties of UniformGridLayout and FlowLayout interpret orientation the opposite to
     // how FlowLayoutAlgorithm interprets it.
     // For simplicity, all of our test validation code is written in terms that match the implementation.
     // For this reason, we need to switch the orientation whenever we set UniformGridLayout.Orientation
     // or StackLayout.Orientation.
     if (layout is StackLayout)
     {
         ((StackLayout)layout).Orientation = scrollOrientation.ToLayoutOrientation();
     }
     else if (layout is UniformGridLayout)
     {
         ((UniformGridLayout)layout).Orientation = scrollOrientation.ToOrthogonalLayoutOrientation();
     }
     else if (layout is FlowLayout)
     {
         ((FlowLayout)layout).Orientation = scrollOrientation.ToOrthogonalLayoutOrientation();
     }
     else
     {
         throw new InvalidOperationException("layout unknown");
     }
 }