# Customize Presentation through UI Layers

**UILayers** provide an extensible approach to showing different parts of **RadRichTextEditor** Document. For example, there are separate layers showing the comments, the selection, the table borders, etc.

The existing layers can be removed and additional ones can be defined to customize the presentation of different parts of the document.

All UILayers implement the **IUILayer** interface. There is an abstract class, which implements this interface -  **DecorationUILayerBase**, and by inheriting it, you can easily define a new layer for custom representations of your document’s layout. The main method to put your logic in is:

```C#
public override void UpdateUIViewPortOverride(UILayerUpdateContext context)
```

```VB.NET
Public Overrides Sub UpdateUIViewPortOverride(ByVal context As UILayerUpdateContext)
```

You can use the context which is passed as a parameter to the method to get all visible layout boxes and perform your decorations and customizations on them. You can also use the **Document** property that your decoration layer inherits from **DecorationUILayerBase** and everything that comes with it (like the current **CaretPosition**).

Last but not least, you should not forget to override the **Name** property of the layer like this:

```C#
public override string Name
{
    get
    {
        return this.customLayerName;
    }
}
```

```VB.NET
Public Overrides ReadOnly Property Name() As String
    Get
        Return Me.customLayerName
    End Get
End Property
```

After having implemented the logic of your custom UI layer, you can plug it in the editor by creating a **CustomUILayerBuilder**.

```C#
public class CustomLayersBuilder : UILayersBuilder
```

```VB.NET
Public Class CustomLayersBuilder
    Inherits UILayersBuilder
```

You can assign the new builder to specific instance of **RadRichTextEditor** like this:

```C#
this.radRichTextEditor1.RichTextBoxElement.UILayersBuilder = new CustomLayersBuilder();
```

```VB.NET
Me.radRichTextEditor1.RichTextBoxElement.UILayersBuilder = New CustomLayersBuilder()
```

All that is left is to specify the place of your layer, i.e. which layers should be shown above and which - below your layer. This is done in the **BuildUILayersOverride** method. For example, a layer can be shown under the selection, after the highlighting layer in the following way:

```C#
protected override void BuildUILayersOverride(IUILayerContainer uiLayerContainer)
{
    uiLayerContainer.UILayers.AddAfter(DefaultUILayers.HighlightDecoration, new CustomDecorationUILayerBase());
}
```

```VB.NET
Protected Overrides Sub BuildUILayersOverride(ByVal uiLayerContainer As IUILayerContainer)
    uiLayerContainer.UILayers.AddAfter(DefaultUILayers.HighlightDecoration, New CustomDecorationUILayerBase())
End Sub
```
