Teoman shipahi
Teoman shipahi

Reputation: 23052

Windows Phone 7 Scoll to Grid's first element

In my WP7 application, I have pager at the end of the page, so people can navigate prev and next.

When I call 2nd page, Grid loads with new items fine but it stays wherever user left the scroll position.

When I was using ListBox element, I achieved this like this;

        ListBox1.UpdateLayout();
        ListBox1.ScrollIntoView(ListBoxEntries.Items[0]); 

but Grid object does not contain ScrollIntoView function. Is there any workaround for this problem?

Upvotes: 0

Views: 91

Answers (1)

Silver Solver
Silver Solver

Reputation: 2320

You can programmatically change the scroll offset of the ScrollViewer like this:

ScrollViewer scroll = myScrollViewer;
Double verticalOffset = 0; //0 for top, otherwise some calculated value.
scroll.ScrollToVerticalOffset(verticalOffset);

Upvotes: 1

Related Questions