Faisal
Faisal

Reputation: 4264

Selectable TextBlock or a TextBox with formatted text in WPF

I have a situation where I need to show a formatted text (normal, bold, highlighted) and should also be selectable so that user can copy the text.

I have used textblock where i can apply multiple formattings using Inline content flow elements but unfortunately it's text is not selectable.

Whereas Textbox allows to select text and copy to clipboard, it does not allow me to format text.

Is there anything I am missing or I'll have to build a custom control?

Upvotes: 2

Views: 2104

Answers (2)

AndreyAkinshin
AndreyAkinshin

Reputation: 19041

You can use RichTextBox. It control is selectable and support formatted tex.

Upvotes: 1

Robert Williams
Robert Williams

Reputation: 1340

I'm not sure how much style you're wanting to apply, but I find the following site to be useful to determine the best way to use Silverlight controls: http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/

This specific URL has some information on how to style a Textbox: http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=TextBoxSnippet

Upvotes: 1

Related Questions