Arslan Pervaiz
Arslan Pervaiz

Reputation: 1643

Listbox Scroll To End In Windows phone 7

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

Answers (1)

Ku6opr
Ku6opr

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

Related Questions