Thaine Norris
Thaine Norris

Reputation: 75

User selecting text in RichTextBox on Windows Phone 8

I am trying to use a RichTextBox in my Windows Phone 8 application. The user needs to be able to select text and copy it to the clipboard. The user DOES NOT need to edit the text, only select it. However, I cannot seem to select text in either the Windows Phone Emulator, or on my Windows Phone 8 device (Nokia 920).

The documentation for the RichTextBox.Selection property contains example code for how to change the format of the selected text (bold, italic, etc.). I would assume that the user would have to select text before he can make it bold or italic, but I cannot make it work. The documentation page is dated November 8, 2012 and states at the bottom that it applies to Windows Phone 8.0 and 7.1. See the page here: http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.windows.controls.richtextbox.selection(v=vs.105).aspx

The documentation on the RichTextBox.IsReadOnly property says that the RichTextBox is always read only on Windows Phone. Indeed, looking at the object in the debugger reveals that IsReadOnly is true. Trying to set it to false throws an exception.

However, elsewhere in the earlier "Mango" documentation, it states that, while the control is read only, the user can still select text. This is clearly implied by the documentation on the RichTextBox.Selection property.

Can someone confirm or deny that user-text-selection is possible in a RichTextBox on a Windows Phone? If it is possible, can someone provide example code of how to make it work?

Thank you!

Thaine Norris

Upvotes: 3

Views: 1846

Answers (1)

Neil Turner
Neil Turner

Reputation: 2727

The RichTextBox was originally ported from Silverlight to Windows Phone 7.1 but not all features were ported (eg. copy & paste and text selection):

WP7 Mango RichTextBox support for copy&paste

Windows Phone Developer Forums: Cannot Select Text in RichTextBox?

After comparing the APIs and doing some testing in the emulator and on device, it looks like the RichTextBox has not been improved for Windows Phone 8 and is still missing that functionality.

Upvotes: 2

Related Questions