#393 – Canvas Element

The Canvas panel serves as a container for a collection of child elements and allows positioning its children using exact coordinates (in WPF Units).

You can specify the following attached properties for a child element of the Canvas, to control how the child element is positioned.

  • Left – Distance between left side of element and left side of canvas
  • Top – Distance between top side of element and top side of canvas
  • Right – Distance between right side of element and right side of canvas
  • Bottom – Distance between bottom side of element and bottom of canvas

If you don’t specify values for any of these properties for a child element, it will be positioned in the upper left corner of the Canvas.

    <Canvas>
        <Label Content="Pease Porridge Hot"/>
        <Label Content="Pease Porridge Cold" Canvas.Left="99" Canvas.Top="23" />
        <Button Content="In the Pot" Canvas.Left="55" Canvas.Top="63" />
        <TextBox Text="Nine Days Old" Canvas.Left="161" Canvas.Top="111" />
    </Canvas>

Advertisements