When I set the SizeToContent="WidthAndHeight" property in my window, WPF renders weird lines around my window:
Is there anything I can do to avoid this?
When I set the SizeToContent="WidthAndHeight" property in my window, WPF renders weird lines around my window:
Is there anything I can do to avoid this?
Copyright © 2021 Jogjafile Inc.

These artifacts sometimes appear due to sizes not fitting pixel boundaries. You can mitigate the effects by setting
UseLayoutRoundingtotrueon root elements or alternatively settingSnapsToDevicePixelsto child controls. From the documentation:In your code, you can set it to the root
Windowlike this:Please note, that
UseLayoutRoundingandSnapsToDevicePixelsare not exactly the same. Choose what fits your requirements best. Here is a source for further reading on the latter: