2

I just started diving into WPF. First thing I noticed and which I really hate is the ugly rendering.

I don't know why but for example borders or lines turning ugly sometimes. Take a look at the Screenshot. The bottom line is ugly. Not that crisp like the centered line.

Any suggestions to make that better?

Ugly Line Rendering

H.B.
  • 142,212
  • 27
  • 297
  • 366
René Stalder
  • 2,516
  • 4
  • 30
  • 50

2 Answers2

5

See the second answer of this SO question which suggests using UseLayoutRounding=False in preference to SnapsToDevicePixels.
As an aside if you're using bitmaps then RenderOptions.BitmapScalingMode can be useful (from this SO question

Community
  • 1
  • 1
Ricibob
  • 7,307
  • 5
  • 42
  • 63
4

It looks like your lines don't fall on pixel boundaries. Two ways I've used to get around this are:

Use SnapsToDevicePixels. This can cause some noticeably odd spacing if you have lines sufficiently close together.

or

Increase the width of your line so that it full hits a line of pixels. (this has the drawback that the needed width is, again, device dependent).

N_A
  • 19,627
  • 4
  • 49
  • 97