2013-09-27 74 views

回答

1

打開MainPage.xaml文件並將代碼替換爲以下內容。

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="ScrollViewerControl.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="400"> 
    <Grid x:Name="LayoutRoot" Background="White"> 
     <ScrollViewer Height="300" Width="300" Name="scrollViewer1" 
        VerticalScrollBarVisibility="Auto" 
        HorizontalScrollBarVisibility="Auto"> 
      <ScrollViewer.Content> 
       <StackPanel> 
        ' Content Here 
       </StackPanel> 
      </ScrollViewer.Content>    
     </ScrollViewer> 
    </Grid> 
</UserControl> 

設置ScollViewer抵消爲零像

scrollViewer1.ScrollToVerticalOffset(0); 

那麼你垂直滾動將永遠在最前面。