Visual.IsPixelSnappingEnabled Свойство

Определение

Возвращает или задает значение, указывающее, выравнивает ли обработчик композиции отображаемый визуальный элемент с границой пикселя.

public:
 property bool IsPixelSnappingEnabled { bool get(); void set(bool value); };
bool IsPixelSnappingEnabled();

void IsPixelSnappingEnabled(bool value);
public bool IsPixelSnappingEnabled { get; set; }
var boolean = visual.isPixelSnappingEnabled;
visual.isPixelSnappingEnabled = boolean;
Public Property IsPixelSnappingEnabled As Boolean

Значение свойства

Boolean

bool

true Значение , если обработчик композиции выравнивает отображаемый визуальный элемент с границой пикселя; в противном случае — false. Значение по умолчанию — false.

Требования к Windows

Семейство устройств
Windows 10, version 2104 (появилось в 10.0.20348.0)
API contract
Windows.Foundation.UniversalApiContract (появилось в v12.0)

Примеры

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;
}

Применяется к