How do I make TextBlock selectable?

How do I make TextBlock selectable?

How do I make TextBlock selectable?

To enable text selection for your control you need to do two things:

  1. Call TextEditor. RegisterCommandHandlers() once to register class event handlers.
  2. Create an instance of TextEditor for each instance of your class and pass the underlying instance of your System. Windows. Documents. ITextContainer to it.

Is TextBlock editable?

TextBlock is not editable.

How do I highlight a textbox in WPF?

You can use the following code to achieve your purpose: textBoxToHighlight. Focus(); textBoxToHighlight. Select(0, textBoxToHighlight.

What is WPF TextBlock?

The WPF TextBlock control is a lightweight text editor control for displaying and formattting small amount of text flow content. The code examples in this tutorial demonstrates how to use a TextBlock control in WPF using XAML and C#. Creating a TextBlock. The TextBlock element represents a WPF TextBlock control in XAML …

What is the textblock in XAML?

Provides a lightweight control for displaying small amounts of text. For more info, design guidance, and code examples, see Text block. If you have the XAML Controls Gallery app installed, click here to open the app and see the TextBlock in action.

How do I select text in a textblock?

This example demonstrates a TextBlock with text selection enabled and text wrapping enabled. If using a keyboard for text selection within a TextBlock, the user must first activate Caret Browsing (with the app in the foreground, press F7).

How do I customize the appearance of a textblock?

This example shows how to customize the appearance of a TextBlock with a single Run of text. The FontWeight, FontFamily, FontStyle, Foreground color, and SelectionHighlightColor properties are customized. The rendered text looks like this:

What are the commonly used properties of textblock class?

Given below are the commonly used properties of TextBlock class. Gets a TextPointer object for the end of text content in the TextBlock. Gets a TextPointer object for the start of text content in the TextBlock.