The Avalon TextBox is an interesting control. Its purpose in life is to edit a string, as opposed to the rich, formatted text editing capabilities of the RichTextBox. One aspect in which the difference can be clearly seen is in the type of objects that are used when programming each control - TextBox will use indices of type int, while RichTextBox will use TextPointer or TextRange objects.
The TextBox control has many members, and I typically think of them as belonging to one of these groups:
- TextBoxBase stuff. These members are shared with RichTextBox, and include undo/redo support, cut/copy/paste support, and programmatic scrolling support.
- Line-sizing stuff. This includes MinLines and MaxLines, which are used to determine how a TextBox will grow and size itself. Eg, if you want a multi-line control that can grow up to four lines of height (after which it displays scroll bars, kind of like some of the Outlook email boxes), you can use write something like this: <TextBox MinLines='1' MaxLines='4' VerticalScrollBarVisibility='Auto' AcceptsReturn='True' />
- Selection stuff. These are properties like SelectionStart and SelectionLength, and methods like Select(). Useful for doing operations on the current selection and highlighting results of a custom search.
- User-input filtering stuff. Note that you can insert text that would not be accepted by the control - this is just to filter things that the user does. This includes properties like CharacterCasing and MaxLength. Useful for a first pass at data validation.
- Line-layout stuff. This group includes a bunch of methods that allow developers to map character indices to lines back and forth, and back points to indices and indices to rectangles. Useful for a variety of tasks, like figuring out what part of the text the cursor is hovering over.