TX Text Control .NET for WPF

Editing Text

Topic

Once a WPF window contains a TextControl, its users can type, select, copy, paste, undo and drag text without a line of code. What your application adds is control: it reads and sets the selection and the caret, puts clipboard and undo commands into its own menus, finds and replaces text, loads dropped files and reacts to keys of its choice. The pages below show how, with XAML and code-behind for each case.

How Editing Works in the WPF TextControl

  • Built in. Typing, mouse and keyboard selection, the clipboard keys, undo and redo, and dragging selected text work as soon as the editor has the keyboard focus.
  • In the ribbon. A window with the WPF ribbon gets a Home tab whose Clipboard group pastes, cuts and copies, and whose Editing group finds, replaces and selects text. See Built-in Ribbon Tabs.
  • In code. The TextControl of the TXTextControl.WPF namespace has methods and properties for the same commands, such as Select, Selection, Copy, Paste, Undo and Find. The classes they return, such as Selection and InputPosition, belong to the TXTextControl namespace and are shared with the Windows Forms product.

Two terms appear on every page. The input position is where typed text appears, shown by the caret. The selection is the highlighted text that the next command changes. Both are counted in text positions, starting with 0 in front of the first character.

Find the Right Page

If you want toRead
Select, read or replace text in code, or track the caretSelections and Caret Position
Put Cut, Copy and Paste into a menu, or paste plain textClipboard Operations
Name undo steps in a menu, or group changes into one stepUndo and Redo
Open the Find and Replace dialog boxes or sidebars, or replace text in codeSearch and Replace
Load files dropped from File ExplorerDrag and Drop
Look up a key, or handle Ctrl+F and other keys yourselfKeyboard Shortcuts

Pages in This Section

Formatting selected text is covered on Text and Paragraph Formatting. Documents that are processed without being shown belong to Document Processing.