Windows Phone ListBox: how to scroll it?

I've got a ListBox (dynamically populated via code):

(i can't insert the code, bah)

I need, with a button, to move this listbox vertically. The listbox have a fixed height, and also the items.

Can someone help me?

Answers


Per MSDN, it looks like this is a viable answer for you? ListBox.ScrollIntoView Method

Edit - Comment Summary of Answer: The question here was targetting scrolling itself, not to a particular object. As such, the necessary action was to attain a reference to the ListBox's ScrollViewer. From there, a call needed to be placed to the ScrollViewer's ScrollToVerticalOffset method. As the OP wanted to scroll down a certain amount from the original position, the ScrollViewer's VerticalOffset property was incorporated into the call.


This works. Set the ListBox to not scroll, then add a ScrollViewer around it. Now in your code behind you can set the ScrollViewer to whatever you want.

XAML:

<!--Disable the ListBox scroll and add a ScrollViewer so we have control over the scroll position.-->
    <ScrollViewer 
             Name="scrlvwrListBoxMessages"
             VerticalScrollBarVisibility="Auto" >
        <ListBox x:Name="lstbxMessages"
             ScrollViewer.VerticalScrollBarVisibility="Disabled" >
</ListBox>
</ScrollViewer>

Code:

    private void ScrollToBottom()
    {
        //Scroll to the bottom.
        Dispatcher.BeginInvoke(() =>
        {
            this.scrlvwrListBoxMessages.ScrollToVerticalOffset(double.MaxValue);
        });
    }

Need Your Help

Variable length integer encoding

c# encoding compression integer bit-manipulation

I am attempting to reverse engineer an LZ1/LZ77 decompression algorithm. The length of an area of the decode buffer/window to be output is encoded in the file as a variable length integer. I've ...

Is there a way to create nice installable applications with GUI and hard lock licenses from python just like we create in Visual Studio?

python ironpython nsis py2exe pyinstaller

I am familiar with cx_freeze, py2exe and pyInstaller that convert python scripts to executable programs which can be further bundled with NSIS as windows installers.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.