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.

 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. 這是因為只有子樹中的最外層元素必須指定 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