ListView DragDrop滚动条无法正常工作

时间:2014-12-11 16:58:10

标签: wpf listview drag-and-drop

ListView上的DragDrop会拖动VerticalScrollBar上的拖动 拖动ScrollBar并且ScrollBar不移动时,DragDrop事件将触发 我仍然可以点击ScrollBar的上方和下方,它会移动并且DragDrop不会发射 如果我在单击ListView内部之前这样做,我可以拖动ScrollBar 如果您需要我发布更多代码,请告诉我

<ListView Grid.Row="6" Grid.Column="0" x:Name="lbFields" VerticalContentAlignment="Stretch" 
    SelectedIndex="-1"
    ItemsSource="{Binding Source={x:Static Application.Current}, Path=MyGabeLib.FieldDefsAppliedGeneralUserNoTextMatch}"                  
    ScrollViewer.VerticalScrollBarVisibility="Visible" BorderThickness="0" Margin="1,1,1,1"
    AllowDrop="True"
    MouseMove="lbFields_MouseMove"                    
    DragDrop.Drop="ListView1_DragDrop">

1 个答案:

答案 0 :(得分:2)

您可以通过将MouseMove事件处理程序放在ListView上的项目的数据模板上而不是ListView本身来解决此问题。

&#13;
&#13;
<ListView Grid.Row="6" Grid.Column="0" x:Name="lbFields" VerticalContentAlignment="Stretch" SelectedIndex="-1" ItemsSource="{Binding Source={x:Static Application.Current}, Path=MyGabeLib.FieldDefsAppliedGeneralUserNoTextMatch}" ScrollViewer.VerticalScrollBarVisibility="Visible"
BorderThickness="0" Margin="1,1,1,1" AllowDrop="True" DragDrop.Drop="ListView1_DragDrop">
  <ListView.ItemTemplate>
    <DataTemplate>
      <Grid MouseMove="lbFields_MouseMove">
        <!-- Add content here -->
      </Grid>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>
&#13;
&#13;
&#13;