Scroll to bottom of listbox wp7
I have a listbox with more than 20 items. How I can scroll to bottom of it?
I tried the Scroll开发者_开发技巧IntoView
method, but no success:
listmy.SelectedIndex = listmy.Items.Count;// listmy.Items.Count - 1;
listmy.ScrollIntoView(listmy.SelectedIndex);
listmy.UpdateLayout();
The ScrollIntoView method expects an object (the item to scroll to), but you are passing in the numeric index of the selected item. This will work:
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
listmy.SelectedIndex = listmy.Items.Count - 1;
listmy.ScrollIntoView(listmy.SelectedItem);
}
Call UpdateLayout before ScrollIntoView
var item = listmy.Items[listmy.Items.Count - 1];
listmy.UpdateLayout();
listmy.ScrollIntoView(item);
listmy.UpdateLayout();
精彩评论