A
A
Ai Lab2016-01-08 08:28:29
.NET
Ai Lab, 2016-01-08 08:28:29

How to make a list scroll with the mouse in WPF?

In general, the essence of the question is in the title, there is a list that is filled dynamically with something like this:

<ScrollViewer Height="256">
                <ListBox x:Name="ResultList" ItemsSource="{Binding}" HorizontalAlignment="Stretch" >
                    <ListBox.ItemTemplate>
                        <DataTemplate DataType="local:Line">
                            <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                                <TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="{Binding Title}" Width="80"/>
                                <TextBlock x:Name="textBlock1" TextWrapping="Wrap" Text="{Binding Text}" Width="280"/>
                                <TextBlock x:Name="textBlock2" TextWrapping="Wrap" Text="TextBlock"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>

Everything is displayed well, but the list will not scroll with the mouse, only with a scrollbar. The question is how to make it work with the mouse?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Bogdanov, 2016-01-08
@Danov

Why ScrollViewer? ListBox itself supports scrolling. Both mouse and scrollbar.
Remove the ScrollViewer and the mouse wheel will scroll.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question