# 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:

```XAML
<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](https://www.telerik.com/products/wpf/documentation/controls/raddocking/features/compass) are available.

![WPF RadDocking with All Compasses Enabled](https://www.telerik.com/products/wpf/documentation/assets/f73eb54de3588357c17986e3fbcf5d5d/raddocking_howto_conditionaldocking_010.png)

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

Attach to the **PreviewShowCompass** event of the **RadDocking** control.

```XAML
<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**.

```C#
private void radDocking_PreviewShowCompass(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e)
{
    e.Compass.IsLeftIndicatorVisible = false;
}
```

```VB.NET
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](https://www.telerik.com/products/wpf/documentation/assets/8dddef565397b461cd854c164547da02/raddocking_howto_conditionaldocking_020.png)

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

```C#
private void radDocking_PreviewShowCompass1(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e)
{
    e.Compass.IsLeftIndicatorVisible = false;
    e.Compass.IsTopIndicatorVisible = false;
}
```

```VB.NET
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](https://www.telerik.com/products/wpf/documentation/assets/e203fb17ba68e3e78adc3968239491e1/raddocking_howto_conditionaldocking_030.png)

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

```C#
private void radDocking_PreviewShowCompass2(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e)
{
    e.Compass.IsLeftIndicatorVisible = false;
    e.Compass.IsTopIndicatorVisible = false;
    e.Compass.IsRightIndicatorVisible = false;
}
```

```VB.NET
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](https://www.telerik.com/products/wpf/documentation/assets/42f8a0b1c7788795e432ba1fe2e64908/raddocking_howto_conditionaldocking_040.png)

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

```C#
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;
}
```

```VB.NET
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](https://www.telerik.com/products/wpf/documentation/assets/b0328c5d01d5d3d3139d470e2bbb9aca/raddocking_howto_conditionaldocking_050.png)

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

```C#
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;
}
```

```VB.NET
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.

> tip There is an alternative approach to disable the docking. You need to set the initial position of the [RadSplitContainer](https://www.telerik.com/products/wpf/documentation/controls/raddocking/styles-and-templates/styling-the-radsplitcontainer) to **FloatingOnly**.

## See Also

* [Compass](https://www.telerik.com/products/wpf/documentation/controls/raddocking/features/compass)

* [Drag and Drop](https://www.telerik.com/products/wpf/documentation/controls/raddocking/features/drag-and-drop)

* [How to Freeze the Layout](https://www.telerik.com/products/wpf/documentation/controls/raddocking/how-to/freeze-the-layout)
