简体   繁体   中英

WPF - Multiline TextBox text gets blurry while typing a long text

I have a textBox that grows vertically while typing. Unfortunately when I type a long text (for example a 3 line text) some PART of it gets blurry. What's more, when I prevent it from growing vertically and make it grow horizontally it works fine - the text is sharp then.

What I've tried:

UseLayoutRounding = true;
RenderOptions.TextRenderingMode = "ClearType";

Please forget about

TextOptions.TextFormattingMode = "Display"

It has to be "Ideal".

See the screenshots:

在此处输入图片说明 在此处输入图片说明

Disable SubPixel Rendering and Anti-Aliasing. Try

SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);

Since you mentioned:

I have a textBox that grows vertically while typing

I assume then that it's a CustomControl derived from TextBox and with a custom rendering to grow vertically instead of using the builtin text wrap ability .

Since I was unable to reproduce your issue with the stock TextBox and the parameters (with Ideal ) you mentioned ( I've checked from Framework 4.0 to 4.6 on VS 2013 ), maybe the blur comes from your custom code .

By the way, with not using the builtin wrap?

TextWrapping="Wrap"

Maybe you should include more code and details, like framework version, visual studio version, OS version and so on.

Likewise, specify your version of "Textbox that grows vertically". Something like this ?

Try increasing the font size of the textbox just a tiny amount (use 1/4s if in pixels). Alternatively, try changing the line height slightly in a similar fashion. I think the problem might be down to WPF's interpretation of the sub-pixels and may be rounding off at the wrong place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM