Canvas

Canvas is the most basic panel, because it supports only the “classic” notion of positioning elements with explicit coordinates. You can position elements in a Canvas by using its Left and Top properties. These properties are special attached properties that can be attached to other elements. Listing 6.1 demonstrates this, introducing previously unseen XAML syntax designed specifically for attached properties.

LISTING 6.1 Buttons Arranged in a Canvas

<Page ...>  <Canvas x:Name="canvas">    <Button Background="Red">Left=0, Top=0</Button>    <Button x:Name="b" Canvas.Left="25" Canvas.Top="25"             Background="Orange">Left=25, Top=25</Button>  </Canvas></Page>

When the XAML parser encounters this

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.