Autoscrolling in GridView while drag drop

3 posts, 0 answers
  1. Martin
    Martin avatar
    1 posts
    Member since:
    Mar 2012

    Posted 19 Apr 2013 Link to this post

    Hi all,

    i have got an issue in using drag and drop functionality in combination with autoscrolling in GridView.
    I must be able to select a cell in gridview and the target cell can only be made visible with scrolling up (may be the target cell is on the upper side of grid and source cell is contained in last row).
    So, if I try to pick up the source cell drag and drop may be initialized and if i move mouse cursor up gridview does not autoscroll up if i come closer and closer to the also visible column headers.

    Is there any way to implement it? If yes it would be very very cool if someone can post a solution for it. :)

    We use RadGridview in combination with the  DragDropManage (without "and").

    Regards
    Martin
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 23 Apr 2013 Link to this post

    Hi Martin,

    Have you implemented any custom logic to "Autoscroll" when you drag, or do you expect this to be done out of the box? 
    If that is the case you can look into this example to see how this can be done.

    <telerik:RadGridView x:Name="RadGridView1" GroupRenderMode="Flat"
                                 ShowGroupPanel="False" CanUserResizeRows="True"
                                 ItemsSource="{Binding Customers}"
                                 RowStyle="{StaticResource DraggedRowStyle}"
                                 AllowDrop="True"
                                 CanUserSortColumns="False"
                                 IsFilteringAllowed="False"
                                 local:RowReorderBehavior.IsEnabled="True"
                                 telerik:ScrollingSettingsBehavior.IsEnabled="True"
                                 telerik:ScrollingSettingsBehavior.ScrollAreaPadding="30"
                                 telerik:ScrollingSettingsBehavior.ScrollStep="24"
                                 telerik:ScrollingSettingsBehavior.ScrollStepTime="00:00:00.05">

    Hope this helps!  Regards,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Mark
    Mark avatar
    14 posts
    Member since:
    Sep 2012

    Posted 31 Jul 2013 Link to this post

    Hi all,

    i had the same issue as Martin and use also the ScrollingSettingBehaviour.

    Now I have the problem, that the dragged item a GridViewCell lose his DataContext in the moment,
    that the cell is no longer visible because of scrolling.

    GridView:
    <telerik:RadGridView x:Name="Grid"
                  Grid.Row="0"
                  AutoGenerateColumns="True"
                  AutoGeneratingColumn="AutoGeneratingColumn"
                  CanUserDeleteRows="False"
                  CanUserFreezeColumns="False"
                  CanUserInsertRows="False"
                  CanUserResizeColumns="True"
                  CanUserSortColumns="False"
                  ColumnWidth="*"
                  GridLinesVisibility="None"
                  IsFilteringAllowed="False"
                  IsReadOnly="True"
                  ItemsSource="{Binding AllRows}"
                  MouseDoubleClick="OnMouseDoubleClick"
                  RowIndicatorVisibility="Collapsed"
                  SelectionUnit="Cell"
                  ToolTipService.IsEnabled="True"
                  ShowGroupPanel="False"
                  telerik:ScrollingSettingsBehavior.IsEnabled="True"
                  telerik:ScrollingSettingsBehavior.ScrollAreaPadding="30"
                  telerik:ScrollingSettingsBehavior.ScrollStep="24"
                  telerik:ScrollingSettingsBehavior.ScrollStepTime="00:00:00.05"/>

    Behaviour:
        <Style x:Key="CellStyle"
               BasedOn="{StaticResource {x:Type telerik:GridViewCell}}"
               TargetType="telerik:GridViewCell">
    ...
    <Setter Property="behavior:DragDropBehavior.DragValidationCommand"
          Value="{Binding Path=DataContext.DragValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
    <Setter Property="behavior:DragDropBehavior.DropValidationCommand"
          Value="{Binding Path=DataContext.DropValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
    <Setter Property="behavior:DragDropBehavior.DragOverValidationCommand"
          Value="{Binding Path=DataContext.DragOverValidationCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />
    <Setter Property="behavior:DragDropBehavior.DropCompletedCommand"
          Value="{Binding Path=DataContext.DropCompletedCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wc:ContentPresenter}}}" />

    Has anybody an idea where I made my mistake?
Back to Top