BorderThickness of 1 renders with a 2-pixel thickness - what am I missing here? BorderThickness of 1 renders with a 2-pixel thickness - what am I missing here? wpf wpf

BorderThickness of 1 renders with a 2-pixel thickness - what am I missing here?


I think what you are looking for is to set this property in your XAML :

SnapsToDevicePixels="True"

Ref: Pixel Snapping in WPF Applications: .NET 3.5


The number of pixels that an element takes up will depend on several factors including:

  • The DPI of the screen
  • Transformations on the element or any of its ancestors
  • Where it is rendered in relation to the pixel boundaries of the screen

The numbers you're using should be considered to be relative to each other rather than absolute values in terms of how they are rendered.

Having said that, WPF 4.0 will include Layout Rounding that you can use to reduce cases where lines that are supposed to be the same thickness are rendered differently depending on whether or not they happen to cross a pixel boundary.