9

I have a problem with Visual Studio 2010. It happens when I scroll down/up, for example, in properties window. Its content becomes blurry for milliseconds.

It also happens in my own WPF applications when I use a “ScrollViewer”.

Does anybody know how to solve it?

Jorge V.
  • 93
  • 4

3 Answers3

6

In your own WPF applications it is possible to constrain scroll offsets to device pixels by using a custom IScrollInfo implementation. This is easy enough to do. Note that you will have to get the actual screen DPI to do the calculation.

In Visual Studio there is no "reasonable" way to fix it. Obviously you could hack up the VS.NET executables to include your own IScrollInfo implementation, but I wouldn't recommend it!!

Community
  • 1
  • 1
Ray Burns
  • 62,163
  • 12
  • 140
  • 141
  • In my case (I need 'controls' scrolling instead of text scrolling), using the ScrollViewer property CanContentScroll="True" enables the IScrollInfo capabilities (pageUp, pageDown, lineUp, lineDown) and bluriness disapear. I will study your suggestion (it looks great!) when I need text scrolling. Thank you for the clue! – Jorge V. Nov 18 '10 at 09:55
3

Just about the only way to avoid the problem is to avoid WPF entirely. As nice as it is in some ways, it still1 doesn't get text entirely correct. And yes, WPF is the source of the problem in Visual Studio -- as of VS 2010 they switched parts of it to use WPF.

1"still", in this case referring to the fact that it used to be even worse. As of .NET 4.0 they've fixed some of the most egregious problems, but (as you've seen) it's still not really right.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Thank you for your answer. I hope Microsoft solve it some day... I like WPF but this problem is too annoying. – Jorge V. Nov 17 '10 at 16:04
  • 3
    Actually, as long as you avoid WPF features that allow partial-pixel scroll offsets, WPF 4 does a great job with text scrolling. The default ScrollViewer, unfortunately, does allow arbitrary offsets. So you get those milliseconds of bluriness while the text alignment is recomputed. You can use IScrollInfo to override the partial-pixel transforms and eliminate the bluriness. See my answer for more information. – Ray Burns Nov 18 '10 at 00:47
1

I had the same problem. There is actually a way to fix this while scrolling. Just add those 3 attributes to your content control:

SnapsToDevicePixels="True" UseLayoutRounding="True"  TextOptions.TextFormattingMode="Display"

Just note that the text might not look as smooth as it should while scrolling (instantly goes away once you stop scrolling though)

Riki
  • 1,776
  • 1
  • 16
  • 31