locked
Using Scrollviewer and DragCanvas RRS feed

  • Question

  • I have tried to use the following custom class (http://blogs.msdn.com/llobo/archive/2006/09/06/Scrolling-Scrollviewer-on-Mouse-Drag-at-the-boundaries.aspx) to try to get my objects that I have in my DragCanvas (http://www.codeproject.com/WPF/DraggingElementsInCanvas.asp?msg=1653438) to scroll when my dragcanvas is not all visible. Do anyone else have a solution for getting this to work?

     

    <local:DragDropScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
      <Grid x:Name="MainGrid" Width="Auto">
        <local:DragDropScrollViewer Grid.ColumnSpan="1" Grid.Row="2" Grid.RowSpan="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
          <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,2.27373675443232E-13,0" Width="Auto" Height="Auto"  x:Name="Schedule">
            <Task:DragCanvas Margin="0,0,0,0" x:Name="TaskCanvas"/>
          </Grid>
        </local:DragDropScrollViewer>
      </Grid>
    </local:DragDropScrollViewer>

    Wednesday, December 13, 2006 7:46 PM

Answers

  • I know why it doesn't work.  The DragCanvas doesn't actually perform drag-and-drop.  Crevier's DragDropScrollViewer is using the OnPreviewQueryContinueDrag method to detect when the scrolling should begin.  That method will not be invoked due to a drag in the DragCanvas because the DragCanvas never calls DoDragDrop.

    You might be able to modify the DragDropScrollViewer so that it override OnPreviewMouseMove to trigger the auto-scrolling.

    Wednesday, December 13, 2006 9:05 PM

All replies

  • This is just a shot in the dark, but have you tried setting the DragCanvas's AllowDragOutOfView property to true?
    Wednesday, December 13, 2006 8:22 PM
  • That doesn't seem to work. Plus, I really need to keep my elements within the canvas.

    Any other ideas?

    Thanks.

     

     

    Wednesday, December 13, 2006 8:53 PM
  • I know why it doesn't work.  The DragCanvas doesn't actually perform drag-and-drop.  Crevier's DragDropScrollViewer is using the OnPreviewQueryContinueDrag method to detect when the scrolling should begin.  That method will not be invoked due to a drag in the DragCanvas because the DragCanvas never calls DoDragDrop.

    You might be able to modify the DragDropScrollViewer so that it override OnPreviewMouseMove to trigger the auto-scrolling.

    Wednesday, December 13, 2006 9:05 PM
  • Thanks, I will give it a try.
    Wednesday, December 13, 2006 9:45 PM