How To Constrain RadDocumentPane To DocumentHost

4 posts, 1 answers
  1. KO
    KO avatar
    16 posts
    Member since:
    Apr 2010

    Posted 25 May 2010 Link to this post

    Hello:

    I apologize if I've missed something easy here. I need a way to keep all RadDocumentPanes that I add to the DocumentHost from being dragged to other non-DocumentHost panes. I want my documents either to be able to float, or to dock in the DocumentHost only - I do not want them to be able to dock in any other pane group. I guess this would be the opposite of the CanDockInDocumentHost property - more like CanOnlyDockInDocumentHost.

    I looked at the PreviewShowCompass event but inside that handler I don't see any way to get a reference to the pane that is being dragged, or the container the compass is over. I need to know which pane is being dragged, because I wish to allow all panes but the DocumentHost panes to dock anywhere the user wants them.

    Any way to do this?

    Thank you in advance,

    KO
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 27 May 2010 Link to this post

    Hi KO,

    Thank you for your interest in our controls.

    The only way to achieve this is to use the PreviewShowCompassEventArgs of the PreviewShowCompass event handler. There you can find which Pane you are dragging from the DraggedSplitContainer. And TargetGroup is where the Pane is dropped. Then after you know which is the Pane and the TargetGroup you can cancel the dropping if the place is different from the DocumentHost.
    Hope this helps.

    If you have further questions please let us know.

    All the best,

    Konstantina
    the Telerik team

     


    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. KO
    KO avatar
    16 posts
    Member since:
    Apr 2010

    Posted 27 May 2010 Link to this post

    Thank you, here is what I came up with. I would appreciate your blessing. First is the xaml for the DocumentHost.

    <telerikDock:RadDocking.DocumentHost> 
      <telerikDock:RadSplitContainer x:Name="DocHostContainer">  
        <telerikDock:RadPaneGroup x:Name="DocHost" /> 
      </telerikDock:RadSplitContainer> 
    </telerikDock:RadDocking.DocumentHost> 

    Here is the code-behind.

    private void Docking_PreviewShowCompass(object sender, PreviewShowCompassEventArgs e)  
    {  
        bool isDocument = ((RadPane)((RadPaneGroup)e.DraggedSplitContainer.Items[0]).Items[0]).CanDockInDocumentHost;  
     
        if (isDocument)  
        {  
            if (e.TargetGroup == null)  
                return;  
            if (e.TargetGroup == DocHost)  
                return;  
            e.Canceled = true;  
        }  

    My thinking is that I can tell the dragged pane is one of my document panes if its CanDockInDocumentHost property is true. It is never true for any of my other panes. I don't see a more direct way to test whether it is being dragged over the DocumentHost than to see if the TargetGroup is the RadPaneGroup defined inside the DocumentHost element in the xaml. Or, if there is no TargetGroup (null), which happens when there are currently no other documents inside the DocumentHost.

    This is working fine, but could you please confirm that this method can be depended on? Especially the assumption about the null TargetGroup? I read elsewhere in this forum that SplitContainers are sometimes deleted when their child panes are deleted. Is there any chance that my "DocHostContainer" can ever be deleted behing the scenes?

    Thanks again,

    KO
  5. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 01 Jun 2010 Link to this post

    Hello KO,

    Thank you for the code snippets.

    You are absolutely right. When the TargetGroup is null, then this means that the Pane will be dragged over the DocumentHost. The DocumentHost won't disappear, it will only, if you set the HasDocumentHost property to False. So, your approach is right and you can depend on it.

    If you have any other questions please let us know.

    All the best,
    Konstantina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top