WPF ListView Databound Drag/Drop Auto Scroll

后端 未结 3 749
轻奢々
轻奢々 2021-02-06 09:03

I\'ve been working with Bea\'s solution here for a while and finding it very helpful. Problem now I\'m having is when I drag-n-drop items within or to another ListView control

3条回答
  •  没有蜡笔的小新
    2021-02-06 09:58

    What I did was took advantage of the ListBox.ScrollIntoView method. Basically, when you update your drop target, you can just call this method on it and wpf will do all the work. All you need to know is the index of the drop target item. This handles both vertical and horizontal scrolling.

    this.listView.ScrollIntoView(this.listView.Items[index]);

    When you use this method, your adorner might move with the scrolling ListBox. To fix this, I just set my adorner parent and adorner layer parent to the content of the window at the top of the visual tree (i.e. topWindow.Content).

提交回复
热议问题