Reputation: 1643
I have listbox in my wp7 application. When An Item is Added into It I Want My Scroll Goes To An End.
I Tried This Thing
var Selecteditem = listmy.Items[listmy.Items.Count - 1];
listmy.ScrollIntoView(Selecteditem);
listmy.UpdateLayout();
But Nothing Happened. Is There any other way to do that?
Upvotes: 1
Views: 1652
Reputation: 8126
probably UI is not updated yet just after new item was added. Put all this code into a Dispatcher
block
Dispatcher.BeginInvoke(() =>
{
var Selecteditem = listmy.Items[listmy.Items.Count - 1];
listmy.ScrollIntoView(Selecteditem);
listmy.UpdateLayout();
});
Upvotes: 5