0

Im wondering how i would go about scrolling a list container like ItemsControl up and down by clicking on an item and dragging your mouse up or down, instead of using dragging on a scrollbar using ScrollViewer?

I have googled around but found only results using a scrollbar to scroll up and down a list of items.

Shawn Andrews
  • 1,432
  • 11
  • 24

1 Answers1

1

You can use this attached behaviour that someone wrote:

Use as follows:

<Window x:Class="WpfApp17.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:system="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:WpfApp17"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <ScrollViewer local:TouchScrolling.IsEnabled="True">
        <ItemsControl>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
                    <system:String>#1</system:String>
                    <system:String>#2</system:String>
                    <system:String>#3</system:String>
                    <system:String>#4</system:String>
                    <system:String>#5</system:String>
                    <system:String>#4</system:String>
                    <system:String>#5</system:String>
                    <system:String>#6</system:String>
                    <system:String>#7</system:String>
                    <system:String>#8</system:String>
                    <system:String>#9</system:String>
                    <system:String>#10</system:String>
                    <system:String>#11</system:String>
                    <system:String>#12</system:String>
                    <system:String>#13</system:String>
                    <system:String>#14</system:String>
                    <system:String>#15</system:String>
                    <system:String>#16</system:String>
                    <system:String>#17</system:String>
                    <system:String>#18</system:String>
                    <system:String>#19</system:String>
                    <system:String>#20</system:String>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</Window>
Colin Smith
  • 12,375
  • 4
  • 39
  • 47