积极答复者
RichTextBlock 光标的问题

问题
-
当RichTextBlock的 IsTextSelectionEnabled 属性设置为true的时候,光标在文本框区域显示为“I”形。但是,我再RichTextBlock里还加了一个按钮,超链接。发现不管鼠标是在文本上,还是在按钮上,还是在超链接上,光标始终为“I”形。这似乎不是良好的用户体验。
我需要的结果是
1.文本可选择。(可以不是“I”形)
2.光标在按钮或者超链接上显示为 手型 或者 箭头型
请问有没有什么解决方案?
PS,我感觉微软的小编最近解答问题不积极了,答案也不是那么精确。是不是有什么烦心事啊?你们这么做是打击我们从事win8开发的积极性啊!!!
别紧张,我不是什么好人。。。
答案
全部回复
-
你需要实现一个自定义Button来实现手或箭头,然后再RichTextBlock中使用,
public class LinkButton : Button { private static CoreCursor _handCursor = new CoreCursor(CoreCursorType.Hand, 1); private static CoreCursor _arrowCursor = new CoreCursor(CoreCursorType.IBeam, 2); protected override void OnPointerEntered(Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { base.OnPointerEntered(e); SetHotCursor(true); } protected override void OnPointerExited(Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { base.OnPointerExited(e); SetHotCursor(false); } private void SetHotCursor(bool hot) { Window.Current.CoreWindow.PointerCursor = hot ? _handCursor : _arrowCursor; } }
Thanks! Damon.Tian
- 已建议为答案 Aaron XueModerator 2012年11月21日 8:41
-
Hi,
没发现什么简单的方法来解决。感觉像Damon提到的手动的去设置IsTextSelectionEnabled可能是唯一的办法了(因为I光标总是覆盖掉其他的手势)
Aaron Xue [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.