Question

I am Using silverlight4 I have developed one page when I navigate to this page from Other Silverlight Page the Position is at the bottom of the page .I need to set the Focus on top of the silverlight Page.I am not using ScrollViewer on my Page.

Was it helpful?

Solution

Open MainPage.xaml file and replace the code with the following.

    <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>

set the ScollViewer offset to zero like

scrollViewer1.ScrollToVerticalOffset(0); 

then your vertical scroll will always be on Top.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top