Updating ListView causes refresh of entire PageControl - Solution RRS feed

  • General discussion

  • When I update my listView, the entire page seems to refresh. The following is the problem and how I fixed the issue (in case someone else encounters the same issue.)

    My ListView starts a few hundred pixels on the right side of a pageControl and proceeds off screen in a horizontal layout. I scroll to right so I can see more of the listView. There is a dropdown menu on my page which allows me to filter the contents of the listview. I select an option from the dropdown menu and the ListView successfully updates itself so it only displays the filtered items. However, when the listView updates, the page goes back to the scrolling point where x == 0. I don't wish for the page to go back to its origin scrolling point. I want the page to stay where it is and just have the listView get updated.

    For a split second the ListView's width == 0 and when that happens there's nothing holding the page from scrolling back to the Zero point since the page's entire width for that split second fits within the 100% area of the page.

    To fix this issue, I capture the scrolling position of the element containing the listView before I change the contents of the ListView. Once the ListView's onloadingstatechanged event gets triggered, I then reset the element's scroll positions to what it was before I updated the listView. This fixed the issue.

    The only problem is that the onloadingstatechanged event gets called multiple times after one ListView update and I only want to set the scrolling position once I know the listView has completely updated on the page. However, that is a subject of a different forum thread. For now, I hope this helps someone in the future.

    Friday, October 17, 2014 1:19 PM