O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required