RadDocumentPane reorder event

5 posts, 1 answers
  1. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 20 Jun Link to this post

    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

  2. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 20 Jun in reply to Mingxue Link to this post

    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>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Jun Link to this post

    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.
  5. Mingxue
    Mingxue avatar
    25 posts
    Member since:
    Apr 2016

    Posted 21 Jun in reply to Yana Link to this post

    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?

  6. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jun Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready