Silverlight 4.0 如何设置silverlight页面顶部的滚动位置

Silverlight 4.0 如何设置silverlight页面顶部的滚动位置,silverlight-4.0,scroll,Silverlight 4.0,Scroll,我正在使用silverlight4当我从另一个Silverlight页面导航到此页面时,我开发了一个页面。该位置位于页面底部。我需要将焦点设置在Silverlight页面的顶部。我没有在我的页面上使用ScrollViewer。打开MainPage.xaml文件并用以下代码替换代码 <UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="Scrol

我正在使用silverlight4当我从另一个Silverlight页面导航到此页面时,我开发了一个页面。该位置位于页面底部。我需要将焦点设置在Silverlight页面的顶部。我没有在我的页面上使用ScrollViewer。

打开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>
然后,您的垂直滚动条将始终位于顶部

scrollViewer1.ScrollToVerticalOffset(0);