Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.22 KB

visual_ispixelsnappingenabled.md

File metadata and controls

49 lines (33 loc) · 1.22 KB
-api-id -api-type
P:Windows.UI.Composition.Visual.IsPixelSnappingEnabled
winrt property

Windows.UI.Composition.Visual.IsPixelSnappingEnabled

-description

Gets or sets a value that indicates whether the composition engine aligns the rendered visual with a pixel boundary.

-property-value

true if the composition engine aligns the rendered visual with a pixel boundary; otherwise, false. The default is false.

-remarks

-see-also

-examples

public Visual CreateVisualTree(Compositor compositor)
{
    // Say we have two visuals, one containing an image and one containing text.
    // The image can be resampled and still look fine, but the text looks bad if
    // it doesn't land perfectly on pixel boundaries.
    var root = compositor.CreateContainerVisual();

    var imageVisual = compositor.CreateSpriteVisual();
    ImageLoadingHelper(imageVisual);

    var textVisual = compositor.CreateSpriteVisual();
    TextLoadingHelper(textVisual);

    textVisual.Offset = new Vector3(50, 0, 0);
    textVisual.IsPixelSnappingEnabled = true;

    root.Children.Add(imageVisual);
    root.Children.Add(textVisual);

    return root;
}