locked
Hub.ScollToSection not scrolling... RRS feed

  • Question

  • Hi,

    I've been trying on and off to fix this for a week with no luck. Any help would be much appreciated...

    So I've tried the below code in both OnNavigatedTo and Hub_Loaded with no luck, the code should be fairly self explanatory, I want to scroll to different sections of the Hub depending on where a user has come back from:

    PageStackEntry previousPage = Frame.BackStack.LastOrDefault();
    
                if (previousPage == null)
                {
                    return;
                }
    
                if (Frame.BackStack.LastOrDefault().SourcePageType.Equals(typeof(Grounds)))
                {
                    //this.MainHub.ScrollToSection(HubGrounds);
                    this.MainHub.ScrollToSection(MainHub.Sections[1]);
                }
    
                base.OnNavigatedTo(e);
    Thanks for any help in advance!

    Tuesday, February 3, 2015 7:00 PM

Answers

  • Hi,

    I test the project and investigate it. It seems to the ScrollToSection method can scroll after the hub control can display in the page. So I recommend you can put your codes in hub GotFocus event:

    private void hub_GotFocus(object sender, RoutedEventArgs e)
            {
               PageStackEntry previousPage = Frame.BackStack.LastOrDefault();

               
    if (previousPage == null)
               
    {
                   
    return;
               
    }

               
    if (Frame.BackStack.LastOrDefault().SourcePageType.Equals(typeof(Grounds)))
               
    {
                   
    //this.MainHub.ScrollToSection(HubGrounds);
                   
    this.MainHub.ScrollToSection(MainHub.Sections[1]);
               
    }
    }

    Hope that can help you!

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Wednesday, February 4, 2015 4:07 AM