UIElement.SnapsToDevicePixels 属性

定义

获取或设置一个值,该值确定在呈现过程中,此元素的呈现是否应使用特定于设备的像素设置。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 元数据属性设置为 trueWhen inherited by FrameworkElement or any possible derived classes, FrameworkElement overrides the metadata for this dependency property to set the Inherits metadata property to true. 这样做的结果是,子树中的最外面的元素只需指定 SnapsToDevicePixels 作为 true,该子树的所有子元素将报告 SnapsToDevicePixelstrue,并将具有 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

适用于

另请参阅