在WinRT中更改插入符号的颜色? [英] Change Caret Color in WinRT?

查看:53
本文介绍了在WinRT中更改插入符号的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在WPF和Silverlight中,您可以使用TextBox.CaretBrush设置TextBox的插入符号颜色,但在WinRT中,他们似乎已删除了该属性.因此,现在如果TextBox为深色,则因为默认情况下插入符号颜色为黑色,所以您看不到它,并且如果TextBox的背景颜色为黑色,则插入符号将完全不存在.我发现这完全不合逻辑,必须有一种实用地或其他方式更改插入符号颜色的方法吗?

So in WPF and Silverlight you could set the caret color for TextBox using TextBox.CaretBrush, but in WinRT it seems in all their wisdom they removed this property. So now if the TextBox is a dark color, since it defaults the caret color to black you can't see it, and if the background color of your TextBox is black the caret ceases to exist completely. I find this completely illogical, there has got to be a way to change the caret color, either pragmatically or something?

有人有什么想法吗?

推荐答案

我通过在TextBox上覆盖透明的画布,使用SelectionStart和GetRectFromCharIndex来获取坐标来完成此工作,然后在KeyDown,KeyUp和MouseDown上设置了线的坐标并使用TranslateTransform对其进行移动,效果很好,性能也很棒!

I got this working by overlaying a transparent canvas overtop of the TextBox, using SelectionStart and GetRectFromCharIndex to obtain coordinates, then on KeyDown, KeyUp, and MouseDown I set the coordinates of a Line and use a TranslateTransform to move it, works great and performance is fantastic!

不确定我为什么不先尝试一下,我之前已经在Silverlight和WPF中完成过很多次转换.我猜想WinRt中的细微差别让我陷入了循环...

Not sure why I didn't try this first, I've done Transforms in Silverlight and WPF many times prior. I guess the subtle differences in WinRt kind of threw me for a loop...

这篇关于在WinRT中更改插入符号的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆