New to Telerik UI for WPF? Download free 30-day trial

How to Implement Conditional Docking

There are cases, in which you want to disable the user's ability to dock panes to any of the sides. In this case you need to implement conditional docking.

You could use the PreviewShowCompass event of the RadDocking control in combination with the Is<*>IndicatorVisible series of properties of the Compass class. Where <*> could be one of the following:

  • Left

  • Top

  • Right

  • Bottom

  • Center

For the purpose of this tutorial, the following RadDocking declaration will be used:

<telerik:RadDocking x:Name="radDocking"> 
    <telerik:RadSplitContainer> 
        <telerik:RadPaneGroup> 
            <telerik:RadPane x:Name="radPane" Header="Pane 1"> 
                <TextBlock Text="Some simple text here"/> 
            </telerik:RadPane> 
            <telerik:RadPane x:Name="radPane2" Header="Pane 2"> 
                <TextBlock Text="Some simple text here"/> 
            </telerik:RadPane> 
        </telerik:RadPaneGroup> 
    </telerik:RadSplitContainer> 
</telerik:RadDocking> 

When you try to drag and dock the "Pane 2", then all compass indicators are available.

WPF RadDocking with All Compasses Enabled

In order to implement conditional docking, you need to perform the following instructions.

Attach to the PreviewShowCompass event of the RadDocking control.

<telerik:RadDocking x:Name="radDocking1" PreviewShowCompass="radDocking_PreviewShowCompass"> 

Switch to the code-behind. The PreviewShowCompassEventArgs exposes a Compass property. You need to use the Is<*>IndicatorVisible series of properties of the Compass class in order to disable any of the compass indicators.

  • IsLeftIndicatorVisible - If you want to disable the left compass indicator, then set the IsLeftIndicatorVisible property of the passed event arguments to False.

private void radDocking_PreviewShowCompass(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
{ 
    e.Compass.IsLeftIndicatorVisible = false; 
} 
Private Sub radDocking_PreviewShowCompass(sender As Object, e As Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs) 
    e.Compass.IsLeftIndicatorVisible = False 
End Sub 

WPF RadDocking without Left Compass

  • IsTopIndicatorVisible - If you want to disable the top compass indicator, then set the IsTopIndicatorVisible property of the passed event arguments to False.

private void radDocking_PreviewShowCompass1(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
{ 
    e.Compass.IsLeftIndicatorVisible = false; 
    e.Compass.IsTopIndicatorVisible = false; 
} 
Private Sub radDocking_PreviewShowCompass(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs) 
    e.Compass.IsLeftIndicatorVisible = False 
    e.Compass.IsTopIndicatorVisible = False 
End Sub 

WPF RadDocking without Top and Left Compasses

  • IsRightIndicatorVisible - If you want to disable the right compass indicator, then set the IsRightIndicatorVisible property of the passed event arguments to False.

private void radDocking_PreviewShowCompass2(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
{ 
    e.Compass.IsLeftIndicatorVisible = false; 
    e.Compass.IsTopIndicatorVisible = false; 
    e.Compass.IsRightIndicatorVisible = false; 
} 
Private Sub radDocking_PreviewShowCompass(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs) 
    e.Compass.IsLeftIndicatorVisible = False 
    e.Compass.IsTopIndicatorVisible = False 
    e.Compass.IsRightIndicatorVisible = False 
End Sub 

WPF RadDocking with Only Bottom Compass

  • IsBottomIndicatorVisible - If you want to disable the bottom compass indicator, then set the IsBottomIndicatorVisible property of the passed event arguments to False.

private void radDocking_PreviewShowCompass3(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
{ 
    e.Compass.IsLeftIndicatorVisible = false; 
    e.Compass.IsTopIndicatorVisible = false; 
    e.Compass.IsRightIndicatorVisible = false; 
    e.Compass.IsBottomIndicatorVisible = false; 
} 
Private Sub radDocking_PreviewShowCompass(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs) 
    e.Compass.IsLeftIndicatorVisible = False 
    e.Compass.IsTopIndicatorVisible = False 
    e.Compass.IsRightIndicatorVisible = False 
    e.Compass.IsBottomIndicatorVisible = False 
End Sub 

WPF RadDocking without Any Compasses

  • IsCenterIndicatorVisible - If you want to disable the center compass indicator, then set the IsCenterIndicatorVisible property of the passed event arguments to False.

private void radDocking_PreviewShowCompass4(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
{ 
    e.Compass.IsLeftIndicatorVisible = false; 
    e.Compass.IsTopIndicatorVisible = false; 
    e.Compass.IsRightIndicatorVisible = false; 
    e.Compass.IsBottomIndicatorVisible = false; 
    e.Compass.IsCenterIndicatorVisible = false; 
} 
Private Sub radDocking_PreviewShowCompass(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs) 
    e.Compass.IsLeftIndicatorVisible = False 
    e.Compass.IsTopIndicatorVisible = False 
    e.Compass.IsRightIndicatorVisible = False 
    e.Compass.IsBottomIndicatorVisible = False 
    e.Compass.IsCenterIndicatorVisible = False 
End Sub 

In the last case, all compass indicators are disabled.

There is an alternative approach to disable the docking. You need to set the initial position of the RadSplitContainer to FloatingOnly.

See Also

In this article