C# WPF 中的 SnapsToDevicePixels 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/780770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:54:13  来源:igfitidea点击:

What does SnapsToDevicePixels in WPF mean in layman terms?

c#snapstodevicepixels

提问by abmv

Anybody? Say I have a Window Class and I give SnapsToDevicePixels = true? what happens?

有人吗?假设我有一个 Window 类并且我给 SnapsToDevicePixels = true?发生什么了?

采纳答案by Joey

It will enable pixel snappingfor every element in your window as this property is inherited by child UI elements. It won't have an effect on the appearance of the window itself, though (i.?e. window frame or similar), since windows reside on integral coordinates on the screen already, anyway.

它将为窗口中的每个元素启用像素对齐,因为此属性由子 UI 元素继承。但是,它不会对窗口本身的外观产生影响(即窗口框架或类似物),因为无论如何窗口已经位于屏幕上的积分坐标上。

回答by Jiang Zhanchang

If so,your will enable pixel snap rendering throughout the UI.For devices operation at greater than 96 dot per inch (dpi),pixel snap rendering can minimize anti-aliasing visual artifacts in the vicinity of single-unit solid lines.And all child elements of that subtree will then report SnapToDevicePixesas true and will have the SnapToDevicePixes visual effect.

如果是这样,您将在整个 UI 中启用像素捕捉渲染。对于大于 96 点/英寸 (dpi) 的设备操作,像素捕捉渲染可以最大限度地减少单单元实线附近的抗锯齿视觉伪影。和所有子然后,该子树的元素将SnapToDevicePixes报告为 true,并将具有 SnapToDevicePixes 视觉效果。