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

RadDocumentPane reorder event

4 Answers 120 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Mingxue
Top achievements
Rank 1
Mingxue asked on 21 Jun 2016, 12:06 AM

Hi, I have two questions regarding recorder in RadDocumentPane.

1. I am using RadDocumentPane to host several panes. I would like to allow users to reorder these panes by drag and drop any of the tabs. In the same time, I have a RadTreeView, which contains the same panes like RadDocumentPane. I would like to be able to get notified when user finished reordering the tabs in RadDocumentPane so that I can sync it to my RadTreeView. What event should I subscribe to in the RadDocumentPane? So far I have tried Drop, DragDrop.Drop, none of these triggers when I finished reorder and drop onto RadDocumentPane.

2. Also, I would like to change the order in RadTreeView, and sync it to RadDocumentPane. By DragDrop in RadTreeView, I could reorder these view models, and I am doing this:

        public void UpdatePanes(IEnumerable<BasePaneViewModel> pages)
        {
            if(pages == null || Panes == null) return;

            foreach (var page in pages)
            {
                Panes.Remove(page);
                Panes.Add(page);
            }
        }

Would this be a good way to recorder in RadDocumentPane or if there is better way to do it?

 

Thanks.

Mingxue

4 Answers, 1 is accepted

Sort by
0
Mingxue
Top achievements
Rank 1
answered on 21 Jun 2016, 12:12 AM

FYI, this is how I implement my RadDocking.DocumentHost

===================Styles==================

        <Style x:Key="MainPageStyle" TargetType="telerik:RadDocumentPane">
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock FontSize="16"
                                   Foreground="DimGray"
                                   Text="{Binding}"/>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Header" Value="{Binding Header, Mode=TwoWay}" />
            <Setter Property="IsHidden" Value="{Binding IsHidden, Mode=TwoWay}" />
            <Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}" />
            <Setter Property="CanUserClose" Value="{Binding CanUserClose, Mode=TwoWay}" />
        </Style>

===================RadDocumentHost==================

           <telerik:RadDocking.DocumentHost>
                <telerik:RadSplitContainer Drop="RadSplitContainer_Drop">
                    <telerik:RadPaneGroup x:Name="documentHostGroup"
                                          DisplayMemberPath="Header"
                                          ItemContainerStyle="{StaticResource MainPageStyle}"
                                          ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                          DropDownDisplayMode="Visible"                                         
                                          IsSynchronizedWithCurrentItem="True">
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.DocumentHost>

0
Yana
Telerik team
answered on 21 Jun 2016, 11:22 AM
Hello Mingxue,

You could use PaneStateChange event of RadDocking, however, please note that it's fired as soon as the pane is dragged out of the group, so you will need to use Dispatcher in the event handler in order to get the pane index. Check the following code snippet:

private void dock_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{           
    var pane = e.OriginalSource as RadDocumentPane;
    Dispatcher.BeginInvoke(new Action(() =>
        {
            if (pane.PaneGroup != null)
            {
                var paneIndex = pane.PaneGroup.Items.IndexOf(pane);
            }
        }));           
}

As to the second question - there is no easier way to reorder the panes with code, so you could continue using the current approach.

I hope this will be helpful.

Regards,
Yana
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Mingxue
Top achievements
Rank 1
answered on 21 Jun 2016, 10:57 PM

Thanks for the info. It seems I only need to know the final order, and then sync it to my RadTreeView. How do I know when the pane is dragged out or when it is dropped back? 

Based on your code, I can only think of a way to check paneIndex:

    If paneIndex is -1, which means this pane is not in items (dragged out, and no sync?);

    When paneIndex is valid (dropped back and can sync?);

Would that be good assumption or there is better way to decide?

0
Accepted
Yana
Telerik team
answered on 23 Jun 2016, 07:31 AM
Hi Mingxue,

Yes, that seems a good assumption that you can use in the concrete scenario.

Regards,
Yana
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
Mingxue
Top achievements
Rank 1
Answers by
Mingxue
Top achievements
Rank 1
Yana
Telerik team
Share this question
or