My intention is simple. Create a sort-of panel where the user can scroll through the many controls within that specific panel. The controls within that panel may be buttons, or images, or labels..whatever.
Thing is… If I make my ScrollViewer Vertical, it scrolls but it doesn’t show all of the controls within itself, AND, it doesn’t stay at the point where I scrolled it. And if I make it horizontal, which is how I want it to be, it doesn’t scroll at all… Not one bit.
Below is my code: PLEASE HELP!
<ScrollViewer Height="118" Name="scrollerButtons" Width="362" Canvas.Left="167" Canvas.Top="275" VerticalAlignment="Center">
<StackPanel Height="97" Name="stackPanelButtons" Width="168" Orientation="Horizontal" Canvas.Left="162" Canvas.Top="43" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Width="60" Height="60"> </Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
<Button Width="60" Height="60"></Button>
</StackPanel>
</ScrollViewer>
I have added a bunch of buttons just to test the whole thing. Any help is HIGHLY appreciated. Thank you.
Remove the
Heightattribute from the StackPanel. You are forcing the inner StackPanel to truncate its content. Since the inner StackPanel is smaller (97) than the ScrollViewer (118), there is nothing for the ScrollViewer to scroll. The ScrollViewer expects its content to be larger than the ScrollViewer itself.