Version

Ruler Margin (xamSyntaxEditor)

Topic Overview

Purpose

This topic explains how to configure the ruler margin feature.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

In this topic, you will find information to help you better understand the xamSyntaxEditor’s functions.

This topic provides you with systematic instructions designed to help you get the xamSyntaxEditor up and running as quickly as possible.

This topic covers the text editing capabilities of the xamSyntaxEditor control from both the developer and user’s perspective.

Introduction

Ruler margin summary

The xamSyntaxEditor™ control supports a ruler margin feature using a red dot to identify the location of the caret along the width of the editing area. When enabled the ruler displays at the top of the editing area regardless of splitting being enabled; however, if splitting is enabled 2 rulers will render, one for each split.

The following screenshot shows the xamSyntaxEditor with ruler margin enabled, and the caret positioned at column 15 (1-based):

xamSyntaxEditor RulerMargin.png
Note
Note

You can obtain the current 1-based caret column using the caret’s read-only property CharacterDisplayColumn.

Ruler Margin Configuration Summary

Ruler margin configuration summary chart

The following table lists the configurable aspects of the xamSyntaxEditor’s ruler margin.

Configurable aspect Details Properties

Show or hide the ruler margin

Change the background of the ruler margin

Change the border of the ruler margin

Change the tick marks of the ruler margin

Change the caret position highlight of the ruler margin

Change the numbers of the ruler margin

Show/Hide

Overview

Show or hide the ruler margin.

Property settings

In order to: Use this property: And set it to:

Show the ruler margin

IsRulerMarginVisible

true

Hide the ruler margin

IsRulerMarginVisible

false

Note
Note

You can also show or hide the ruler margin by invoking the ToggleRulerMarginVisibility command.

Code

The following code snippet shows how to make the ruler margin visible:

In C#:

this.xamSyntaxEditor1.IsRulerMarginVisible = true;

In Visual Basic:

Me.xamSyntaxEditor1.IsRulerMarginVisible = True

Change Background Brush

Overview

Change the brush used to fill the ruler margin area.

Property settings

In order to: Use this property: And set it to:

Change the background brush

RulerMarginBackground

An object of type Brush

Code

The following code snippet shows how to set the ruler margin’s background to light gray.

In C#:

this.xamSyntaxEditor1.RulerMarginBackground = new SolidColorBrush(Colors.LightGray);

In Visual Basic:

Me.xamSyntaxEditor1.RulerMarginBackground = New SolidColorBrush(Colors.LightGray)

Change Border Brush

Overview

Change the brush used to draw the rectangle surrounding the ruler margin’s area.

Property settings

In order to: Use this property: And set it to:

Change the border brush

RulerMarginBorderBrush

An object of type Brush

Code

The following code snippet shows how to set the ruler margin’s border to dark gray.

In C#:

this.xamSyntaxEditor1.RulerMarginBorderBrush = new SolidColorBrush(Colors.DarkGray);

In Visual Basic:

Me.xamSyntaxEditor1.RulerMarginBorderBrush = New SolidColorBrush(Colors.DarkGray)

Change Tick Mark Brush

Overview

Change the brush used to draw the ruler margin tick marks.

Property settings

In order to: Use this property: And set it to:

Change the tick marks brush

RulerMarginTickMarkBrush

An object of type Brush

Code

The following code snippet shows how to set the ruler margin’s tick marks to black.

In C#:

this.xamSyntaxEditor1.RulerMarginTickMarkBrush = new SolidColorBrush(Colors.Black);

In Visual Basic:

Me.xamSyntaxEditor1.RulerMarginTickMarkBrush = New SolidColorBrush(Colors.Black)

Change Caret Highlight Brush

Overview

Change the brush used to draw caret position highlight in the ruler margin.

Property settings

In order to: Use this property: And set it to:

Change the caret highlight brush

RulerMarginCaretPositionHighlightBrush

An object of type Brush

Code

The following code snippet shows how to set the ruler margin’s caret highlight to red.

In C#:

this.xamSyntaxEditor1.RulerMarginCaretPositionHighlightBrush =
    new SolidColorBrush(Colors.Red);

In Visual Basic:

Me.xamSyntaxEditor1. RulerMarginCaretPositionHighlightBrush = _
    New SolidColorBrush(Colors.Black)

Change Numbers Brush

Overview

Change the brush used to draw the ruler margin numbers.

Property settings

In order to: Use this property: And set it to:

Change the numbers brush

RulerMarginTextBrush

An object of type Brush

Code

The following code snippet shows how to set the ruler margin’s numbers to black.

In C#:

this.xamSyntaxEditor1.RulerMarginTextBrush = new SolidColorBrush(Colors.Black);

In Visual Basic:

Me.xamSyntaxEditor1.RulerMarginTextBrush = New SolidColorBrush(Colors.Black)

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic describes the use and configuration of the xamSyntaxEditor control’s built-in Line Number Margin.

This topic explains how to create your own margins.

This topic will help you understand the document splitting capability of the xamSyntaxEditor and how to customize it.