在列表视图中更改拖动光标

本文关键字:拖动 光标 列表 视图 | 更新日期: 2023-09-27 18:31:30

我必须创建一个包含可拖动项目的列表视图。我在代码项目中找到了解决方案

http://www.codeproject.com/Articles/17266/Drag-and-Drop-Items-in-a-WPF-ListView?fid=378031&fr=51&df=90&mpp=25&prof=False&sort=Position&view=Normal&spc=Relaxed#xx0xx

这是通过网络找到的最好的代码。现在我需要将拖动 cursoe 更改为 sizeAll。

有什么方法可以更改默认拖动光标吗?

在列表视图中更改拖动光标

我下载了您链接到的程序。

要实现您想要的内容,请在ListViewDragDropManager.cs#region Hook Events区域中添加以下内容:

this.listView.GiveFeedback += listView_GiveFeedback;

然后将其添加到#region Event Handling Methods部分:

private void listView_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
    if (e.Effect == DragDropEffects.Move)
    {
        e.UseDefaultCursors = false;
        Mouse.SetCursor(Cursors.SizeAll);
    }
    else
        e.UseDefaultCursors = true;
    e.Handled = true;
}

不要忘记在#region Unhook Events部分取消订阅:

this.listView.GiveFeedback -= listView_GiveFeedback;