locked
How to scroll the listview to the special item when init the listview.

    Question

  • When I run my app ,there has a listview. 

    I wan't to use the 

    listView.ensureVisible(itemIndex)

    to scroll the listview to the special item;

    but this is dons't work.

    or when using this method?

    Thursday, November 22, 2012 3:46 AM

Answers

  • Also try the indexOfFirstVisible API.
    • Marked as answer by 一兮 Monday, November 26, 2012 2:14 AM
    Friday, November 23, 2012 9:34 AM

All replies

  • Hi,

    You could use that as follow:

    var listview = document.getElementById("basicListView").winControl;
            listview.ensureVisible(41);

    Any more question, please feel free to reply.

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    Friday, November 23, 2012 9:29 AM
  • Also try the indexOfFirstVisible API.
    • Marked as answer by 一兮 Monday, November 26, 2012 2:14 AM
    Friday, November 23, 2012 9:34 AM
  • but this function only take effect when the ListView is ready.

    so,how can i know when the ListView is ready?

    by the way ,thank you reply

    Monday, November 26, 2012 1:06 AM
  • Hi,

    Then put the code in the follow code:

    WinJS.UI.Pages.define("/default.html", {
       ready: function (element, options) {
           // everything in here works beautifully
       }
    });


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    Monday, November 26, 2012 2:16 AM