Rulers and Status Bar
Rulers for margins, indents and tab stops, and a status bar with the page, line and zoom factor, are what users expect around a document. In a WPF window, the RulerBar and the StatusBar of TX Text Control provide them as XAML elements, and most of their settings are attributes you write next to the element. What follows covers the horizontal and the vertical ruler, their scale and cell references, the areas and labels of the status bar, and showing or hiding the bars.
The bars are placed and connected for the first time in Connect Rulers, Toolbars, and a Status Bar.

Place and Connect the Bars
The bars are connected by name: the TextControl holds the x:Name of each bar in RulerBar, VerticalRulerBar and StatusBar, and an empty string means that no bar is connected. The same RulerBar class serves as horizontal and vertical ruler: the vertical ruler is the one named in VerticalRulerBar, docked at the left and stretched vertically. Connect the Bars in XAML in the tutorial Connect Rulers, Toolbars, and a Status Bar declares and connects the bars in a DockPanel, and Connecting Ribbon Tabs in XAML shows them in a complete ribbon window.
Ruler Settings
Each property can be written as an attribute in the XAML or set in code:
| Property | Values and effect |
|---|---|
| ScaleUnit | Auto chooses inches or millimeters by the current culture; Inch; Centimeter without millimeter marks; Millimeter, which is centimeters with millimeter marks |
| EnablePageMargins | True lets users set the page margins on the ruler |
| FormulaMode | Cell references while the input position is in a table cell: None, the default; Always; Auto, only in cells with a formula; Fixed, relative to the cell where the mode was switched on |
| BorderStyle | ColorScheme, Flat, FixedSingle, Simple3D or Fixed3D |
FormulaMode shows references in A1 or R1C1 notation according to TextControl.FormulaReferenceStyle, and has no effect with the border styles Simple3D and Fixed3D. Tables and Table Formulas covers formulas.
Unlike the Windows Forms ruler, the WPF RulerBar has no ReadOnly property; to keep users from changing the document, set the EditMode of the TextControl instead.
Status Bar Settings
The StatusBar shows information about the input position and the document in areas that you switch on and off:
| Property | Area |
|---|---|
| ShowPage, ShowPageCounter | The page of the input position and the number of pages |
| ShowSection, ShowSectionCounter | The section of the input position and the number of sections |
| ShowLine, ShowColumn | The line and the column of the input position |
| ShowLanguage | The language of the selection or the input position |
| ShowKeyStates | CAPS LOCK, NUM LOCK and insert or overwrite mode |
| ShowZoom, ShowZoomTrackBar | The zoom factor, as a number or as a track bar that also sets it |

The reference of the WPF status bar lists a few more properties:
- Font. FontFamily, FontSize,
FontStyleandFontWeightare dependency properties, so they can be set by a style or a binding. - A message of your own. Text shows your text until a status of the connected
TextControlchanges, for example "Document saved" after a save command.
Labels of the Areas
PageText, PageCounterText, SectionText, SectionCounterText, LineText and ColumnText set the labels in front of the values, such as Page:, for example to translate them. BorderStyle takes the values of the ruler and VerticalColorScheme, which the TX Words sample uses.
Configure Both in XAML
The following elements set up a ruler in centimeters with page margins and cell references, and a status bar with sections, key states, a zoom track bar and German labels:
<WPF:RulerBar x:Name="rulerBar" DockPanel.Dock="Top"
ScaleUnit="Centimeter" EnablePageMargins="True" FormulaMode="Auto"/>
<WPF:StatusBar x:Name="statusBar" DockPanel.Dock="Bottom"
ShowSection="True" ShowSectionCounter="True"
ShowKeyStates="True" ShowZoomTrackBar="True"
PageText="Seite" LineText="Zeile" ColumnText="Spalte"
SectionText="Abschnitt" BorderStyle="VerticalColorScheme"/>
In code, the enumerations are in the TXTextControl namespace, for example rulerBar.ScaleUnit = TXTextControl.RulerBarScaleUnit.Centimeter; and statusBar.BorderStyle = TXTextControl.StatusBarBorderStyle.VerticalColorScheme;.
Show and Hide the Bars
- Users, with the ribbon. The Toolbars group of the RibbonViewTab has check boxes for the horizontal ruler, the vertical ruler and the status bar, named
TXITEM_HorizontalRuler,TXITEM_VerticalRulerandTXITEM_StatusBarin RibbonViewTab.RibbonItem. Remove them as described in Built-in Ribbon Tabs if the bars should always be visible. - Your code. The bars are WPF elements, so
verticalRulerBar.Visibility = Visibility.Collapsed;hides the vertical ruler. To detach a bar from the editor instead, set the matching property of theTextControlto an empty string.
The colors of the bars, set with DisplayColors when the border style is ColorScheme, are covered in Styles, Resources, and Themes.
Next Steps
- Toolbars and Mini Toolbars: the button bar and the mini toolbars.
- Viewing, Zooming, and Navigation: zoom and view modes, which the status bar shows.
- Sections and Page Layout: the sections and page margins the bars display.
- Right-to-Left UI: the bars in right-to-left applications.