我想知道如何通过单击项目并向上或向下拖动鼠标来上下滚动像ItemsControl这样的列表容器,而不是使用ScrollViewer在滚动条上拖动?
我搜索了一下,但发现只有使用滚动条向上和向下滚动项目列表的结果。
答案 0 :(得分:0)
您可以使用某人撰写的附加行为:
使用如下:
<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>