# Viewing, Zooming, and Navigation

> Choose a ViewMode, bind or set ZoomFactor, show control characters and markers, and move to a page with InputPosition and GotoDialog in a WPF TextControl.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Document Editor > Viewing, Zooming, and Navigation
- **2757 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/viewing/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/viewing/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/viewing/llms-full.txt

---

Pages with margins or text that fills the window, a zoom factor, visible formatting marks and the page the user is on: these are view settings of the WPF `TextControl`. Several of them are dependency properties, so XAML sets and binds them like the properties of any WPF control. The sections below cover the view modes, zooming, formatting marks, moving to a page and following the position of the user.

Markup and code below go into a window with a `TextControl` named `textControl1` in *MainWindow.xaml*, as in [Create Your First WPF Application](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/first-application/llms-full.txt).

### Choose a View Mode

The layout on the screen follows [ViewMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/viewmode-property/llms-full.txt):

- **`PageView`** shows pages with gaps on a desktop background, formatted with the page size and margins, including headers and footers.
- **`Normal`** formats the text with the page size and margins, but without the page view; headers and footers exist but aren't displayed.
- **`FloatingText`** makes the text as wide as the control, with a vertical scroll bar for text of any length. Page size, margins, headers and footers are ignored.
- **`SimpleControl`** formats the text to the width and height of the control, which accepts no more text once it is full.

Only in `PageView` does the editor count pages. Set the mode as an attribute in XAML:

```xml
<WPF:TextControl x:Name="textControl1" ViewMode="PageView" />
```

The scroll bars follow the WPF conventions: [HorizontalScrollBarVisibility](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/horizontalscrollbarvisibility-property/llms-full.txt) and [VerticalScrollBarVisibility](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/verticalscrollbarvisibility-property/llms-full.txt) take a `ScrollBarVisibility`. `Auto` and `Visible` show a scroll bar when the document doesn't fit, and `Disabled` and `Hidden` never show one. The colors of the control are set with [DisplayColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/displaycolors-property/llms-full.txt), a [TextControlColors](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrolcolors/llms-full.txt) object.

### Zoom the Document

[ZoomFactor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/zoomfactor-property/llms-full.txt) is the zoom factor in percent. Because it is a dependency property, a `Slider` or a `TextBlock` can be bound to it, and both follow when the user zooms in another way, for example with the status bar:

```xml
<TextBlock Text="{Binding ElementName=textControl1, Path=ZoomFactor, StringFormat={}{0} %}" />
```

[Zoom With a Slider](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/data-binding/value-converters/#zoom-with-a-slider) in Value Converters binds a slider through the [LogarithmicConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/logarithmicconverter/llms-full.txt) of TX Text Control, which puts 100 percent in the middle of the slider. In `PageView` and `Normal` mode, the factor can be from 10 up to `ushort.MaxValue` percent; in the other modes, from 10 to 400 percent.

In code, [Zoom](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/zoom-method/llms-full.txt) takes a factor or a value of [ZoomOption](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/zoomoption/enumeration/llms-full.txt): `PageWidth` fits the width of the page into the control, `WholePage` the current page and `TextWidth` the text of a line:

```csharp
private void PageWidthButton_Click(object sender, RoutedEventArgs e)
{
    textControl1.Zoom(ZoomOption.PageWidth);
}
```

`ZoomOption` is in the `TXTextControl` namespace. Unlike the Windows Forms control, the WPF `TextControl` has no `Zoomed` event: bind to `ZoomFactor` instead, as the `TextBlock` above does.

### Show Formatting Marks and Markers

The following properties show what doesn't appear on paper. [ControlChars](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/controlchars-property/llms-full.txt), [TextFrameMarkerLines](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/textframemarkerlines-property/llms-full.txt) and [DrawingMarkerLines](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/drawingmarkerlines-property/llms-full.txt) are dependency properties:

| Property | Shows |
|---|---|
| `ControlChars` | All control characters, such as spaces, tabs and paragraph ends |
| [PermanentControlChars](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/permanentcontrolchars-property/llms-full.txt) | Chosen control characters all the time, combined from [PermanentControlChar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/permanentcontrolchar/enumeration/llms-full.txt) values such as `ParagraphEnd`, `ForcedPageBreak` or `SectionBreak` |
| `TextFrameMarkerLines` | Marker lines around text frames without a border |
| `DrawingMarkerLines` | Marker frames around drawings |
| [DocumentTargetMarkers](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/documenttargetmarkers-property/llms-full.txt) | Markers at hypertext targets, such as bookmarks |

A `CheckBox` bound to `ControlChars` lets the user switch the control characters on and off:

```xml
<CheckBox Content="Show control characters"
          IsChecked="{Binding ElementName=textControl1, Path=ControlChars}" />
```

The **View** tab of the ribbon, a [RibbonViewTab](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/ribbonviewtab/llms-full.txt) that the `TextControl` finds by the name in its [RibbonViewTab](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/ribbonviewtab-property/llms-full.txt) property, offers the views, the zoom factors and these marks without code.

![The View tab of the WPF TX Text Control Words sample with the groups Document Views (Print Layout, Draft), Zoom (Zoom, 100 %, Full Page, Page Width, Text Width), Toolbars, Show and Application View.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-wpf/view-tab-toolbars.e1712c67.webp)

Its **Document Views** group switches between **Print Layout** and **Draft**, the **Zoom** group sets the zoom factor or fits the page, its width or the text width into the control, and the **Show** group turns table gridlines, bookmark markers, marker lines, control characters and frame anchors on and off.

### Go to a Page

A new [InputPosition](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputposition/llms-full.txt) with a page, line and column moves the caret when it is assigned to the [InputPosition](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/inputposition-property/llms-full.txt) property of the control. [ScrollTo](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputposition/scrollto-method/llms-full.txt) brings it into view:

```csharp
private void GoToPageButton_Click(object sender, RoutedEventArgs e)
{
    int page = 3;

    // Pages exist only in page view
    if (textControl1.ViewMode != ViewMode.PageView || page > textControl1.Pages)
    {
        return;
    }

    // Line 1, column 0 is the start of the page
    textControl1.InputPosition = new InputPosition(page, 1, 0);
    textControl1.InputPosition.ScrollTo(InputPosition.ScrollPosition.Top);
    textControl1.Focus();
}
```

What the code does:

- [Pages](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/pages-property/llms-full.txt) is the number of pages of the document.
- The `InputPosition` constructor counts pages and lines from 1 and columns from 0.
- [InputPosition.ScrollPosition](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputposition/scrollposition-enumeration/llms-full.txt) `Top` scrolls the input position to the top of the visible area.
- `Focus` gives the keyboard focus back to the editor after the click on the button.

Outside page view, [GetPages](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/getpages-property/llms-full.txt) returns `null`; in page view, it returns a [PageCollection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagecollection/llms-full.txt), and [Page.Select](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/page/select-method/llms-full.txt) selects the text of one page without its header and footer. The [GotoDialog](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/gotodialog/llms-full.txt), a modeless window of the `TXTextControl.WPF` namespace, lets the user go to a page, section, line, table or bookmark:

```csharp
private void GoToDialogButton_Click(object sender, RoutedEventArgs e)
{
    TXTextControl.WPF.GotoDialog dialog = new TXTextControl.WPF.GotoDialog(textControl1);
    dialog.Show();
}
```

### Follow the Position in the Document

[PageChanged](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/pagechanged-event/llms-full.txt) occurs when the input position has moved to another page. Connect it with `PageChanged="TextControl1_PageChanged"` on the `TextControl` element; [InputPosition.Page](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputposition/page-property/llms-full.txt) returns the page in page view:

```csharp
private void TextControl1_PageChanged(object sender, EventArgs e)
{
    Title = $"Page {textControl1.InputPosition.Page} of {textControl1.Pages}";
}
```

The [StatusBar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/statusbar/llms-full.txt) of TX Text Control for WPF displays the page and the zoom factor without code; see [Rulers and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/rulers-status-bar/llms-full.txt). [HScroll](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/hscroll-event/llms-full.txt) and [VScroll](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/vscroll-event/llms-full.txt) report scrolling, and [ScrollLocation](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/scrolllocation-property/llms-full.txt) is the upper-left corner of the visible part as a `System.Windows.Point` in twips.

### Next Steps

- [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt): the input position and the selection in detail.
- [Sections and Page Layout](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/sections/llms-full.txt): page sizes and margins that the page view shows.
- [Rulers and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/rulers-status-bar/llms-full.txt): the status bar with page number and zoom.
- [Printing and Print Preview](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/printing/llms-full.txt): print what the page view shows.

---

## Nearby

- **Previous:** [Spell Checking and Hyphenation](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/spell-checking/llms-full.txt)
- **Next:** [Printing and Print Preview](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/printing/llms-full.txt)
