Reputation: 176
im trying to make something in WPF but i have one problem. Ive placed some elements to the window so in editor it looks thus:
In build it looks thus:
And if i place to element->
RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased"
In build it look now:
I really dont know how to solve it so i will be really grateful that someone will help me
Upvotes: 1
Views: 1627
Reputation: 9089
This is usually related to not having SnapsToDevicePixels
set.
Pixel Snapping in WPF Applications
In your control or window, you can set it by doing
<MyControl SnapsToDevicePixels="True">
The WPF graphics system uses device-independent units to enable resolution and device independence. Each device independent pixel automatically scales with the system's dots per inch (dpi) setting. This provides WPF applications proper scaling for different dpi settings and makes the application automatically dpi-aware.
However, this dpi independence can create irregular edge rendering due to anti-aliasing. These artifacts, commonly seen as blurry, or semi-transparent, edges can occur when the location of an edge falls in the middle of a device pixel rather than between device pixels. To address this issue, WPF provides a way for object edges in a visual tree to snap, or become fixed, to device pixels through pixel snapping, eliminating the semi-transparent edges produced by anti-aliasing.
Pixel snapping is a means to suppress these visual artifacts by applying small offsets to the geometry of the visual to align the geometry to device pixels.
Upvotes: 4