0
votes

I ran into a little bug while creating a scrollable stackpannel. I used the scrollviewer. I have placed the Stackpannel inside the Scrollviewer but I can't scroll using a emulator.. I don't have a windows phone so I cant check it out on an actual phone. Here is my code:

 <ScrollViewer Height="979" Margin="0,100,0,-439" VerticalAlignment="Stretch">
        <StackPanel Height="979" VerticalAlignment="Stretch" Width="268">

        // things inside the stackpannel

        </StackPanel>
    </ScrollViewer>

Am I doing something wrong or does the scrollviewer not work in an emulator?

1
Never use a StackPanel directly under a ScrollViewer, use a Grid instead. - Justin XL
Why?? Do you have any explanation or sources to explain? - Filip Skakun
Remove Height and Margin values from the ScrollViewer. - Filip Skakun

1 Answers

3
votes

The height of the ScrollViewer is the same as the height of the StackPanel so there is nothing to scroll (it just falls off the end of the screen). Try using VerticalAlignment="Stretch" instead of setting Height on the ScrollViewer which should help (if not, you have some other problem in your layout ;-) but using a fixed, smaller Height for the ScrollViewer will solve this immediate problem).