For example,
if you set this property to 10, the first selected character is the 11th character in the text box.
The Selection Length indicates the total number of selected characters. (A value of 0 indicates
no selected characters.) Finally, the SelectedText property allows you to quickly examine or
change the selected text in the text box. You can react to the selection being changed by handling
the SelectionChanged event. Figure 7-6 shows an example that reacts to this event and
displays the current selection information.
Figure 7-6. Selecting text
The TextBox class also includes one property that lets you control its selection behavior:
AutoWordSelection. If this is True, the text box selects entire words at a time as you drag
through the text.
Miscellaneous TextBox Features
The TextBox includes a few more specialized frills. The most interesting is the spelling-checker
feature, which underlines unrecognized words with a red squiggly line. The user can rightclick
an unrecognized word and choose from a list of possibilities, as shown in Figure 7-7.
To turn on this spelling-checker functionality for the TextBox control, you simply need to
set the SpellCheck.IsEnabled dependency property, as shown here:
...The spelling checker is WPF-specific and doesn??™t depend on any other software (such as
Office).
Pages:
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404