punker76/gong-wpf-dragdrop

Performance issues when dragging an item in a ListView

OronDF343 opened this issue · 4 comments

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>

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

@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