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

How To Constrain RadDocumentPane To DocumentHost

3 Answers 80 Views
Docking
This is a migrated thread and some comments may be shown as answers.
KO
Top achievements
Rank 1
KO asked on 25 May 2010, 10:23 PM
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

3 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 27 May 2010, 03:40 PM
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.
0
KO
Top achievements
Rank 1
answered on 28 May 2010, 12:02 AM
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
0
Accepted
Konstantina
Telerik team
answered on 01 Jun 2010, 03:08 PM
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.
Tags
Docking
Asked by
KO
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
KO
Top achievements
Rank 1
Share this question
or