Welcome to the Xceed Community | Help
Community Search  
More Search Options

Automatically scroll to the newly added item

Sort Posts: Previous Next
  •  02-01-2012, 4:31 AM Post no. 31629

    Automatically scroll to the newly added item

    Hi,

    imagine a contest where there are few items in the list with scroll-bar.  When a new item is added at run-time, the item get added at the end of the list and it need to scroll till the end to see if the item was added or not.

    is it possible that when item is added it scrolls automatically to that newly added item ?

     thanks in advance,

    Sunil

  •  02-02-2012, 9:48 AM Post no. 31633 in reply to 31629

    Re: Automatically scroll to the newly added item

    Attachment: AddNewItemTest.zip

    Hi Sunil,

     You could scroll to a specific item by using ScrollIntoView() on the ListBox and passing it the newly added item. Depending on your underlying collection, you could for example use the CollectionChanged event to in the handler, scroll to the newly added item there:


          People.CollectionChanged += new NotifyCollectionChangedEventHandler( People_CollectionChanged );

           void People_CollectionChanged( object sender, NotifyCollectionChangedEventArgs e )
        {
          if( e.Action == NotifyCollectionChangedAction.Add )

            listbox.ScrollIntoView( e.NewItems[ 0 ] );
        }

     Also find attached a basic sample that demonstrates this.

     


    Best Regards,

    Michel Dahdah
    Technical Support
    Xceed Software inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.