The code snippet below sets the scroll to the last item of the list
//Array of numbers var array = [2, 3, 4, 5, 6, 7, 8, 9, 10]; //Bind the array to list var list = new WinJS.Binding.List(array); var listView = document.getElementById("basicListview").winControl; //Set the itemDataSource property of basicListview listView.itemDataSource = list.dataSource; //The function accepts a single argument, which is a function to execute, and it inserts //this function to be executed as soon as the UI thread is idle window.msSetImmediate(function () { //Set the scroll to the last item of the list listView.ensureVisible(list.length -1); });
The code snippet below set the scroll to the last item of the list
//Array of numbers var array = [2, 3, 4, 5, 6, 7, 8, 9, 10]; //Bind the array to list var list = new WinJS.Binding.List(array); var listView = document.getElementById("basicListview").winControl; //Set the itemDataSource property of basicListview listView.itemDataSource = list.dataSource; //The function accepts a single argument, which is a function to execute, and it //this function to be executed as soon as the UI thread is idle window.msSetImmediate(function () { //Set the scroll to the last item of the list listView.ensureVisible(list.length -1 }); //The setImmediate() frees the browser from needing to manage a timer for this process. //Instead of waiting for a system interrupt, which uses more power, the browser can simply wait for //the UI queue to empty and then insert the new JavaScript task.
N.B Currently, only Internet Explorer 10 supports setImmediate(),and it does so through msSetIntermediate() since the specification is not yet finalized.