Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone How to Vertical Scroll

I'm just starting out in WinPhone development and can't figure out how to set the vertical scroll. For example i've started a new Pivot App, and this code allows the user to scroll up and d own to see all the entries:

<controls:PivotItem Header="Login">
    <!--Double line list with text wrapping-->
    <ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}">
        <ListBox.ItemTemplate>
            <DataTemplate>
              <StackPanel Margin="0,0,0,17" Width="432" Height="78">
                  <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                  <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
              </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</controls:PivotItem>

Now when, I add my own pivot item, with a stackpanel with more items than can be seen on the screen at any one time, it will not allow me to scroll to see them all. What am I missing here?

Thanks.

like image 541
Darren Young Avatar asked Feb 18 '12 16:02

Darren Young


2 Answers

Add ScrollViewer over the StackPanel and it will make it scrollable.

like image 113
MarcinJuraszek Avatar answered Sep 28 '22 16:09

MarcinJuraszek


The ListBox in the example code that you supplied ha built-in scrolling functionality. However, if you are not using something that already has this scrolling functionality in it, you will have to add a ScrollViewer.

<controls:PivotItem Header="Example">
    <ScrollViewer Margin="12,0,12,0">
        <StackPanel>
            <TextBlock Text="Example1" FontSize="150" />
            <TextBlock Text="Example2" FontSize="150" />
        </StackPanel>
    </ScrollViewer>
</controls:PivotItem>
like image 38
Bryan Watts Avatar answered Sep 28 '22 16:09

Bryan Watts