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.
  • 166,899
  • 29
  • 327
  • 400
René Stalder
  • 2,536
  • 5
  • 31
  • 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,505
  • 5
  • 46
  • 65
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,799
  • 4
  • 52
  • 98