问题描述
我正在尝试在我的 Windows Phone 8 应用程序中使用 RichTextBox.用户需要能够选择文本并将其复制到剪贴板.用户不需要编辑文本,只需选择它.但是,我似乎无法在 Windows Phone 模拟器或 Windows Phone 8 设备 (Nokia 920) 中选择文本.
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).
RichTextBox.Selection 属性的文档包含有关如何更改所选文本格式(粗体、斜体等)的示例代码.我认为用户必须先选择文本,然后才能将其设为粗体或斜体,但我无法使其工作.文档页面的日期为 2012 年 11 月 8 日,底部声明它适用于 Windows Phone 8.0 和 7.1.请参阅此处的页面:http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.windows.controls.richtextbox.selection(v=vs.105).aspx
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
有关 RichTextBox.IsReadOnly 属性的文档说明 RichTextBox 在 Windows Phone 上始终是只读的.事实上,查看调试器中的对象表明 IsReadOnly 为真.尝试将其设置为 false 会引发异常.
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.
然而,在早期的Mango"文档的其他地方,它指出,虽然控件是只读的,但用户仍然可以选择文本.RichTextBox.Selection 属性的文档清楚地暗示了这一点.
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.
有人可以确认或否认可以在 Windows Phone 上的 RichTextBox 中进行用户文本选择吗?如果可能,有人可以提供如何使其工作的示例代码吗?
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?
谢谢!
泰恩诺里斯
推荐答案
RichTextBox 最初是从 Silverlight 移植到 Windows Phone 7.1 但并非所有功能都被移植(例如复制和粘贴和文本选择):
The RichTextBox was originally ported from Silverlight to Windows Phone 7.1 but not all features were ported (eg. copy & paste and text selection):
Windows Phone 开发人员论坛:无法在 RichTextBox 中选择文本?
在比较 API 并在模拟器和设备上进行一些测试后,看起来 RichTextBox 尚未针对 Windows Phone 8 进行改进,并且仍然缺少该功能.
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.
这篇关于用户在 Windows Phone 8 上的 RichTextBox 中选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!