我可以通过拖动行项目而不是滚动条来滚动ItemsControl [英] Can i scroll an ItemsControl by dragging row items instead of scrollbar

查看:63
本文介绍了我可以通过拖动行项目而不是滚动条来滚动ItemsControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何通过单击一个项目并上下拖动鼠标来上下滚动像ItemsControl这样的列表容器,而不是使用ScrollViewer在滚动条上拖动吗?

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?

我在Google周围搜索,但是使用滚动条上下滚动项目列表只能找到结果.

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

推荐答案

您可以使用某人写的以下附加行为:

You can use this attached behaviour that someone wrote:

用法如下:

<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>

这篇关于我可以通过拖动行项目而不是滚动条来滚动ItemsControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆