Search code examples
c#silverlightwindows-phone-7xamlexpression-blend

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?


Solution

  • 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(); 
    });