punker76 / gong-wpf-dragdrop

The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issues when dragging an item in a ListView

OronDF343 opened this issue · comments

commented

Tested on both 0.1.4.3 and 1.0.0-ALPHA012
Dragging an item in the ListView causes low frame rate in the UI due to high CPU usage.
Using the diagnostic tools and dragging an item up and down, I found that GongSolutions.Wpf.DragDrop.DragDrop.DragSource_PreviewMouseMove was called over 3000 times, and almost every time (all except for 2) it calls System.Windows.DragDrop.DoDragDrop which causes all of the CPU usage.
Here is the code of the ListView: (Note: changing the SelectionMode doesn't make a difference)

<ListView Grid.Row="2"
          ItemsSource="{Binding PlaylistManager.SelectedPlaylist}"
          SelectionMode="Multiple"
          dragDrop:DragDrop.IsDragSource="True"
          dragDrop:DragDrop.IsDropTarget="True">
    <ListView.View>
        <GridView>
            <GridViewColumn DisplayMemberBinding="{Binding Tag.Title}" Header="Title"/>
            <GridViewColumn DisplayMemberBinding="{Binding Tag.JoinedPerformers}" Header="Performers"/>
            <GridViewColumn DisplayMemberBinding="{Binding FileName}" Header="File name"/>
            <GridViewColumn DisplayMemberBinding="{Binding Bitrate}" Header="Bitrate"/>
            <GridViewColumn DisplayMemberBinding="{Binding Duration}" Header="Duration"/>
        </GridView>
    </ListView.View>
</ListView>
commented

Anyone taken a look at this? System.Windows.DragDrop.DoDragDrop should not be called on every MouseMove...

@OronDF343 You're not right, this line is only called once (just create a break point with some message and continue execution)

var result = System.Windows.DragDrop.DoDragDrop(m_DragInfo.VisualSource, data, m_DragInfo.Effects);
commented

@punker76 You're right, it is only called once (back then I had used a bad profiler)
However, the performance issues still exist, and they happen only when I move the mouse over a different item in the ListView. I can't seem to figure out what's causing it.

@OronDF343 This performance issue should be fixed now