Horizontal Scrolling
Introduction
InnerPanelInstance and Horizontal Scrolling
var scrollViewer = new ScrollViewer();
scrollViewer.AddToRoot();
scrollViewer.Anchor(Anchor.Center);
var visual = (ScrollViewerVisual)scrollViewer.Visual;
visual.InnerPanelInstance.Dock(Dock.SizeToChildren);
// Now any child added to the scrollviewer will cause it to expand:
var random = Random.Shared;
for (int i = 0; i < 10; i++)
{
var coloredRectangle = new ColoredRectangleRuntime();
scrollViewer.AddChild(coloredRectangle);
coloredRectangle.X = random.Next(0, 150);
// no need to specify Y - the scroll viewer already
// stacks its children
coloredRectangle.Red = (byte)random.Next(0, 256);
coloredRectangle.Green = (byte)random.Next(0, 256);
coloredRectangle.Blue = (byte)random.Next(0, 256);
}
HorizontalScrollBarVisibility
Last updated
Was this helpful?

