<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.Graphics.RectangleExample" WindowTitle="Example"> <Canvas> <TextBlock VerticalAlignment="Center">Snapped:</TextBlock> <Rectangle SnapsToDevicePixels="True" Margin="10" Height="10" Fill="Red"></Rectangle> </Canvas> </Page>