This is a migrated thread and some comments may be shown as answers.

Deferred Drag mode and RadGrid rows reordering

2 Answers 126 Views
Docking
This is a migrated thread and some comments may be shown as answers.
BENN
Top achievements
Rank 1
BENN asked on 10 May 2016, 06:23 AM

It seems that the two don't get along. Code:

<Window x:Class="DeferredModeAndRowsReorder.MainWindow"
        xmlns:local="clr-namespace:DeferredModeAndRowsReorder"
        Title="MainWindow" Height="350" Width="525" WindowState="Maximized">
     
    <Grid>
        <Grid.Resources>
            <Style TargetType="telerik:GridViewRow"
                   x:Key="DraggedRowStyle">
                <Setter Property="telerik:DragDropManager.AllowDrag"
                        Value="True" />
                <Setter Property="telerik:DragDropManager.TouchDragTrigger"
                        Value="TapAndHold"/>
            </Style>
        </Grid.Resources>
         
        <telerik:RadDocking x:Name="radDocking" DragDropMode="Deferred" CloseButtonPosition="InPaneAndGroup">
            <telerik:RadDocking.DocumentHost>
                <telerik:RadSplitContainer x:Name="dh">
                    <telerik:RadPaneGroup x:Name="dg">
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.DocumentHost>
 
            <telerik:RadSplitContainer telerik:DockingPanel.InitialSize="170,150" MaxWidth="600"
                    Name="LeftContainer" InitialPosition="DockedLeft">
                <telerik:RadPaneGroup x:Name="Group1">
                    <telerik:RadPane CanUserClose="False" x:Name="Pane1" Header="Server Explorer" CanDockInDocumentHost="False">
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
 
            <telerik:RadSplitContainer telerik:DockingPanel.InitialSize="170,150" MaxWidth="600" Orientation="Vertical"
                    Name="RightContainer" InitialPosition="DockedRight">
                <telerik:RadPaneGroup x:Name="Group2">
                    <telerik:RadPane CanUserClose="False" x:Name="Pane2" Header="Toolbox" CanDockInDocumentHost="False">
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
 
                <telerik:RadPaneGroup x:Name="Group3">
                    <telerik:RadPane CanUserClose="False" x:Name="Pane3" Header="Properties" CanDockInDocumentHost="False">
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
 
            <telerik:RadSplitContainer telerik:DockingPanel.InitialSize="170,300" Orientation="Horizontal"
                    Name="BottomContainer" InitialPosition="DockedBottom">
                <telerik:RadPaneGroup>
                    <telerik:RadPane CanUserClose="False" Header="System" CanDockInDocumentHost="False">
                    </telerik:RadPane>
                    <telerik:RadPane CanUserClose="False" IsSelected="True" Header="Global" CanDockInDocumentHost="False">
                    </telerik:RadPane>
                    <telerik:RadPane CanUserClose="False" Header="Watch" CanDockInDocumentHost="False">
                        <telerik:RadGridView x:Name="RadGridView1" GroupRenderMode="Flat"
                             ShowGroupPanel="False" CanUserResizeRows="True"
                             ItemsSource="{Binding Items}"
                             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">
                            <telerik:RadGridView.Resources>
                                <DataTemplate x:Key="DraggedItemTemplate">
                                    <StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Dragging:" />
                                            <TextBlock Text="{Binding CurrentDraggedItem}"
                                       FontWeight="Bold" />
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding CurrentDropPosition}"
                                       FontWeight="Bold"
                                       MinWidth="45" />
                                            <TextBlock Text=", ("
                                       Foreground="Gray" />
                                            <TextBlock Text="{Binding CurrentDraggedOverItem}" />
                                            <TextBlock Text=")"
                                       Foreground="Gray" />
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:RadGridView.Resources>
                        </telerik:RadGridView>
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </Grid>
</Window>

 

And I just generated a simple items source in the code behind:

     public partial class MainWindow : Window
    {
        private ObservableCollection<int> _items = new ObservableCollection<int>();
 
        public MainWindow()
        {
            InitializeComponent();
 
            for (int i = 0; i < 1000; i++)
            {
                _items.Add(i);
            }
 
            this.DataContext = this;
        }
 
        public ObservableCollection<int> Items
        {
            get
            {
                return _items;
            }
        }
    }

 

The row reorder behavior code is taken from your examples. When trying to reorder rows, then I see the deferred mode adorner and the docking compasses.

This is not the only problem. Try reordering the rows... After few drag and drops (Usually a quick drag and drop), the "Watch" pane (where the GridView was in) will disappear (because it was removed from its original group and added a some group with no items).

 

2 Answers, 1 is accepted

Sort by
0
BENN
Top achievements
Rank 1
answered on 10 May 2016, 12:07 PM
I see that handling the drag initialized event in the behavior fixes the problem.Is that the correct solution?
0
Accepted
Nasko
Telerik team
answered on 11 May 2016, 10:10 AM
Hi Benn,

Handling the event is exactly what you need to use in order to make everything work as expected. As RadDocking in Deferred mode uses internally our DragDropManager if the event of the GridView is not handled the built-in drag and drop logic of the handler of the GridView will not be executed and as you have noticed the DragDrop functionality of the Docking control will be used.

Hope that information will be helpful for you.

Regards,
Nasko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Docking
Asked by
BENN
Top achievements
Rank 1
Answers by
BENN
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or