0

I found the sample code of "Nick Miller" on the following question: mvvm how to make a list view auto scroll to a new Item in a list view

This partly answers my question because scrolling works very close, but I need the user can stop automatic scrolling.

To do this I added a checkbox, and in the eveinement puts it true or false the variable listbox.autoscroll, but this has no effect despite the fact that the code will change the property.

I have not changed the Nick Miller code on the LoggingListBox class.

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Test_Listbox_Autoscroll"
        xmlns:tools="clr-namespace:Test_Listbox_Autoscroll"
        mc:Ignorable="d"
        Title="MainWindow" Width="800"
         SizeToContent =" WidthAndHeight">
    <Grid>
        <StackPanel >

            <tools:LoggingListBox x:Name="Listbox1"
                              Margin=" 10"
                              Background="Bisque"
                              Height="180"
                              ItemsSource="{Binding LST_ListBox1_Collection}"
                              SelectedItem="{Binding LST_ListBox1_SelectedItem}"/>
            <CheckBox x:Name="ChkAutoScroll"
                      Margin="10"
                      Content="Auto Scroll"
                      Click="ChkAutoScroll_Click"/>
        </StackPanel>

    </Grid>
</Window>

Private Sub ChkAutoScroll_Click(sender As Object, e As RoutedEventArgs)
    If (ChkAutoScroll.IsChecked = True) Then

        Listbox1.AutoScroll = True
    Else

        Listbox1.AutoScroll = False
    End If
End Sub

There is no error message, but scrolling is still active despite the AutoScroll value change.

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55
Chris SV
  • 1
  • 1

0 Answers0