0
votes

How call some function when User scroll ListBox to end? I try ro use ScrollToBottom bit this doesn't work!

3

3 Answers

0
votes

Try this :

myListBox.ScrollIntoView(myListBox.Items.Count);

The above will not work if your listbox item is a control, the reason is this scrolls to the top of the item and not the bottom.

0
votes

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);
        });
    }
-1
votes

There is no method named "ScrollToBottom" in Silverlight ListBox

Try this :

myListBox.ScrollIntoView(myListBox.Items.Count);