Senin, 12 Agustus 2013

Use Canvas Panel Control in WPF

Canvas is the basic panel. One can simply place children in a canvas with its attached properties left, top, right and bottom. One should have some knowledge of graph paper to use a canvas panel in WPF. This works as margin property of an element.

I have placed some buttons in a canvas as in following image:


The buttons in above image can be simply placed by using following xaml code:
<Canvas>
<Button Content="First" Canvas.Left="10" Canvas.Top="10"></Button>
<Button Content="Second" Canvas.Top="10" Canvas.Right="10"></Button>
<Button Content="Third" Canvas.Bottom="50" Canvas.Right="50"></Button>
</Canvas>

It is the most lightweight panel for creating flexible user interfaces. One should keep it in mind for maximum performance when one need precise control over the placement of elements. A child can use only two of the canvas attached properties at a time, remaining will be ignored. It means one cant dock an element to more than one corner of a canvas.

Tidak ada komentar:

Posting Komentar