UIElement.SnapsToDevicePixels UIElement.SnapsToDevicePixels UIElement.SnapsToDevicePixels UIElement.SnapsToDevicePixels Property

定义

获取或设置一个值,该值确定在呈现过程中,此元素的呈现是否应使用特定于设备的像素设置。Gets or sets a value that determines whether rendering for this element should use device-specific pixel settings during rendering. 这是依赖项属性。This is a dependency property.

public:
 property bool SnapsToDevicePixels { bool get(); void set(bool value); };
public bool SnapsToDevicePixels { get; set; }
member this.SnapsToDevicePixels : bool with get, set
Public Property SnapsToDevicePixels As Boolean

属性值

如果元素应按照设备像素呈现,则为true ;否则为 falsetrue if the element should render in accordance to device pixels; otherwise, false. UIElement 上声明的默认值为 falseThe default as declared on UIElement is false.

注解

可以在根元素上将true此属性设置为, 以在 UI 中启用像素对齐呈现。You can set this property to true on your root element to enable pixel snap rendering throughout the UI. 对于在大于 96 每英寸点数 (dpi)dots per inch (dpi)的设备上运行的设备, 像素对齐呈现可以最大程度地减少单单元实线附近的抗锯齿视觉对象。For devices operating at greater than 96 每英寸点数 (dpi)dots per inch (dpi), pixel snap rendering can minimize anti-aliasing visual artifacts in the vicinity of single-unit solid lines.

当由或FrameworkElement任何可能的派生类继承FrameworkElement时, 将重写此Inherits依赖项属性的元数据, true以将元数据属性设置为。When inherited by FrameworkElement or any possible derived classes, FrameworkElement overrides the metadata for this dependency property to set the Inherits metadata property to true. 这样做的结果是, 子树中只有最外面的元素需要SnapsToDevicePixelstrue指定为, 然后该子树的所有子元素将SnapsToDevicePixels报告true为, 并将SnapsToDevicePixels具有视觉效果。What this achieves is that only the outermost element in a subtree needs to specify SnapsToDevicePixels as true, and all child elements of that subtree will then report SnapsToDevicePixels as true and will have the SnapsToDevicePixels visual effect.

依赖项属性信息Dependency Property Information

标识符字段Identifier field SnapsToDevicePixelsProperty
元数据属性设置为trueMetadata properties set to true NoneNone

适用于

另请参阅