Search code examples
wpfgraphicsantialiasing

WPF DrawingContext seems ignore SnapToDevicePixels


I'm drawing a chart by direct calls to DrawLine on the DrawingContext. Since I want to avoid any anti aliasing feature, I tryed to put the SnapToDevicePixels=true on the parent UIElement, but I still have anti-alias:

enter image description here

The project was an old OS project not written for WPF4, but I retarget it to the Framework4, can this be an issue too ?


Solution

  • SnapsToDevicePixels works only for element bounding box. You need to use Guidelines with DrawingContext. Also you can specify VisualXSnappingGuidelines and VisualYSnappingGuidelines if it fits to your requirements.