The big boss again hit you “Hey buddy, I don’t want to see those movement layers in the inserted table those you are using in the Silverlight application”. Now as a developer what to do? You are using the Telerik RadRichTextBox in the application that you are building. Does it provide the functionality?

Today’s blog post is on that topic and here we will discuss, how to hide the movement layer from the table and then show it back again on need basis.

Telerik controls are always a best choice for most of the companies and developers when building applications. If you are a Silverlight application developer and using the RadRichTextBox control in your application to provide the end user to use the Tables, you might have noticed that there is a UI movement layer in the selected table.

What is UI movement layer? UI Movement layer is a tiny box placed at the top left corner of the table by which you can reposition your table inside the Telerik’s RadRichTextBox control. It also creates a little border around the table. Check out the following screenshot for details:

Now as your boss (client) asked, you have to remove it at any cost. But what if the underlying API does not provide anything! You searched in the RadRichTextBox table properties and didn’t find anything. Now what to do?

Don’t worry. You can do this easily. Telerik APIs provide you classes to handle this UILayer. This is not only valid for UI Movement Layer, but also applicable for total 34 different UI layers as mentioned below:

PagesLayer

LinesDocumentLayer

HeaderFooterLayer

HyperlinksLayer

BackgroundsLayer

ImagesLayer

FloatingBlocksBackLayer

UIContainerLayer

WatermarkLayer

NotesSeparatorLayer

TableRevisionRangesDecoration

FootnotesLayer

RevisionChangedLinesDecoration

EndnotesLayer

HighlightDecoration

FloatingBlocksFrontLayer

HighlightFieldsDecoration

TableCellBordersResizeLayer

StrikethroughDecoration

CommentsLayer

ProofingErrorsDecoration

AdornerLayer

UnderlineDecoration

ForegroundLayer

DocumentListDecoration

SelectionLayer

BordersDecoration

HeaderFooterOverlayLayer

FloatingBlockAnchorDecoration

TableMovementLayer

FormattingSymbolsLayer

ToolTipLayer

TabLeaderUILayer

NotesTooltipLayer

In this blog post, we are going to discuss how to hide the UI movement layer. If you want to do it for other layers, the implementation is same as shown in the example.

First of all, create a class named “CustomUILayerBuilder” inheriting “UILayerBuilder” class provided by Telerik present under the “Telerik.Windows.Documents.UI.Layers” namespace. Now override the “BuildUILayersOverride(…)” method which takes IUILayerContainer as parameter. You don’t have to pass anything here as the underlying framework will take care this automatically. Remove the TableMovementLayer from the passed IUILayerContainer as shown in the below code snippet:

Now when you attach this code to your RadRichTextBox control, the said layer will be removed from the control and will not be visible to the end user any more. When you want to bring it back to the UI, just assign a new instance of the default UILayerBuilder to it and that will bring back all the UI layers to their original state.

// Set custom UI layer when you want to hide it

radRichTextBox.UILayersBuilder = new CustomUILayerBuilder();

// Set it back to default when you want to show it

radRichTextBox.UILayersBuilder = new UILayersBuilder();

If you have multiple layers and you want to show or hide them individually, you might have to expose property or method to handle it properly. This is not a common requirement but in some case you may want to implement it in your Silverlight application. If you are using Telerik RadControls and asked to do the same on business requirement, I hope this post will guide you. Let me know, if it was helpful and in case any queries, drop a line below and I will try to answer you as soon as I can. But I will suggest you to check out the Telerik forums to get them answered quickly.

About Me

Kunal Chowdhury is a Windows Platform Development MVP of Microsoft, a Telerik MVP, Nokia Developer Champion, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.