public void TestScrollOf(bool virtualizeItems) { var stackSize = new Vector3(100, 200, 300); var childSize1 = new Vector3(50, 150, 250); var childSize2 = new Vector3(150, 250, 350); var childSize3 = new Vector3(250, 250, 350); var stackPanel = new StackPanel { Size = stackSize, ItemVirtualizationEnabled = virtualizeItems, Orientation = Orientation.Horizontal, LayoutingContext = new LayoutingContext() }; var child1 = new StackPanel { Size = childSize1 }; var child2 = new StackPanel { Size = childSize2 }; var child3 = new StackPanel { Size = childSize3 }; stackPanel.Children.Add(child1); stackPanel.Children.Add(child2); stackPanel.Children.Add(child3); stackPanel.Arrange(Vector3.Zero, false); // pre-arranged stackPanel.ScrollOf(childSize1); Utilities.AssertAreNearlyEqual(1, stackPanel.ScrollPosition); stackPanel.ScrollOf(childSize1); Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition); // post arranged stackPanel.InvalidateArrange(); stackPanel.ScrollOf(childSize1); Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition); stackPanel.Arrange(Vector3.Zero, false); Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition); stackPanel.InvalidateArrange(); stackPanel.ScrollOf(- 2 *childSize1); Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition); stackPanel.Arrange(Vector3.Zero, false); Utilities.AssertAreNearlyEqual(1, stackPanel.ScrollPosition); }