Поделиться через


UIElement.UseLayoutRounding Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that determines whether rendering for the object and its visual subtree should use rounding behavior that aligns rendering to whole pixels.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property UseLayoutRounding As Boolean
public bool UseLayoutRounding { get; set; }

Property Value

Type: System.Boolean
true if rendering and layout should use layout rounding to whole pixels; otherwise, false. The default is true.

Remarks

Dependency property identifier field: UseLayoutRoundingProperty

The default of true will cause measurement and layout operations to round potential subpixel values, and render objects aligned to pixel boundaries. This behavior is intended to reduce the visual artifacts that can be perceived when a subpixel value renders and affects pixels on either side of the subpixel boundary. The most prominent example of such an artifact is when you intend to produce a crisp, thin line of a particular color. If your measurement for line gave a subpixel value, and the layout behavior did not round to whole pixels, then the line can potentially appear blurry as well as appearing as a dimmer color shade than you intended.

Setting UseLayoutRounding to false is not generally recommended, and possible scenarios for doing so are not documented here. Ultimately, if you feel that there might be benefit in enabling subpixel rendering for your application, experiment with setting UseLayoutRounding to false, examine the visual results, and make sure that possible rendering artifacts from subpixel rendering do not outweigh the perceived benefits. If you do set UseLayoutRounding to false, always do so on the root of your XAML page or object tree.

NoteNote:

In general, you should not specify the default of true explicitly, either in code or XAML. Doing so will interfere with porting your code or XAML to WPF, because UseLayoutRounding is not in the WPF XAML vocabulary or available as a CLR property of UIElement for WPF.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.