Search code examples
c#xamlscrollwindows-8.1

How to scroll view in windows 8.1 programmatically?


I have a windows 8.1 view: For example:

MyPage.xaml

<Grid>
<Hub>
<HubSection x:Name"FirstSection">
<Button x:Name="NavigateToThirdSection" Tapped="NavigateToThirdSection_Tapped"></Button>
</HubSection>
<HubSection x:Name"SecondSection">
</HubSection>
<HubSection x:Name"ThirdSection">
<TextBlock Text="Third Section.."></TextBlock>
</HubSection>
</Hub>
</Grid>

MyPage.xaml.cs

private void StackPanel_Tapped(object sender, TappedRoutedEventArgs e)
{
//What Should I do to reach the third HubSection end of the page when I click the button at the first HubSection
}

I need to reach the end of the page horizontally when I click at the button at the begin of page.

Regards,


Solution

  • First of all give Hubname MainHub or etc...

    private void StackPanel_Tapped(object sender, TappedRoutedEventArgs e)
    {
        //What Should I do to reach the third HubSection end of the page when I click the button at the first HubSection
        MainHub.ScrollToSection(ThirdSection);
    }