# Editing Text

> Editing text in the WPF TextControl: selections, clipboard, undo, find and replace, dropped files and keys, with XAML and code-behind for your own commands.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Document Editor > Editing Text
- **887 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/llms-full.txt

---

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](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/ribbon-ui/ribbon/llms-full.txt).
- **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 to | Read |
|---|---|
| Select, read or replace text in code, or track the caret | [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt) |
| Put Cut, Copy and Paste into a menu, or paste plain text | [Clipboard Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/clipboard/llms-full.txt) |
| Name undo steps in a menu, or group changes into one step | [Undo and Redo](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/undo-redo/llms-full.txt) |
| Open the Find and Replace dialog boxes or sidebars, or replace text in code | [Search and Replace](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/search-replace/llms-full.txt) |
| Load files dropped from File Explorer | [Drag and Drop](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/drag-drop/llms-full.txt) |
| Look up a key, or handle Ctrl+F and other keys yourself | [Keyboard Shortcuts](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/keyboard-shortcuts/llms-full.txt) |

### Recommended Order

1. [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt), because every other page works with the selection and text positions.
2. The page of the command you are adding.
3. [Keyboard Shortcuts](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/keyboard-shortcuts/llms-full.txt) before you assign keys, to avoid those the editor already uses.

### Pages in This Section

- [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt) — text positions, `Select`, `Selection`, `InputPosition` and the mouse actions.
- [Clipboard Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/clipboard/llms-full.txt) — `Copy`, `Cut`, `Paste`, clipboard formats and document permissions.
- [Undo and Redo](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/undo-redo/llms-full.txt) — undo commands, action names, grouped steps and `IsUndoEnabled`.
- [Search and Replace](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/search-replace/llms-full.txt) — dialog boxes, sidebars, `Find` and replacing in all text parts.
- [Drag and Drop](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/drag-drop/llms-full.txt) — moving text, drop formats and dropped files.
- [Keyboard Shortcuts](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/keyboard-shortcuts/llms-full.txt) — the built-in keys and a `KeyDown` handler for your own.

Formatting selected text is covered on [Text and Paragraph Formatting](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/formatting/llms-full.txt). Documents that are processed without being shown belong to [Document Processing](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-processing/llms-full.txt).

---

## In This Section

- [Clipboard Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/clipboard/llms-full.txt): Put Cut, Copy and Paste into a WPF menu, enable items with CanCopy and CanPaste, paste one ClipboardFormat such as plain text and respect document permissions.
- [Drag and Drop](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/drag-drop/llms-full.txt): Set AllowDrag and AllowDrop in XAML, open files dropped from File Explorer and insert dropped images at the drop point in the WPF DragEnter and Drop handlers.
- [Keyboard Shortcuts](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/keyboard-shortcuts/llms-full.txt): Look up the built-in keys of the WPF TextControl, add Ctrl+F and Ctrl+H in a KeyDown handler and make Enter insert a line break with PreviewKeyDown.
- [Search and Replace](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/search-replace/llms-full.txt): Find and replace text in WPF: built-in dialog boxes, a Replace sidebar in XAML, Find with FindOptions, a Replace All loop with one undo step and all text parts.
- [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt): Use Select, Selection and InputPosition in a WPF TextControl to select and replace text, follow the caret and find lines and characters with their bounds.
- [Undo and Redo](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/undo-redo/llms-full.txt): Show undo and redo action names in a WPF menu, group edits into one step with BeginUndoAction and EndUndoAction, call ClearUndo and set IsUndoEnabled in XAML.

---

## Nearby

- **Previous:** [Document Properties](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/properties/llms-full.txt)
- **Next:** [Selections and Caret Position](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/editing-text/selections/llms-full.txt)
