The Canvas is usually an underestimated layout control in Silverlight, instead it's really useful and flexible; one the most usefull things I have discovered while playing with Silverlight is to build pages using a Canvas as the most external container and place any other layout control inside it.

Why? it has a very nice and easy support for Z-Indexing and if you diplay some controls/forms/whatever on top of each other is a very simple task to realize. You can easily build a window-like desktop application in this way.

So here's the way in which I usually define my silverlight pages/applications.

<UserControl x:Class="ContextMenuExtender.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Canvas x:Name="surface"> <StackPanel x:Name="LayoutRoot" Background="White"> ... </StackPanel> </Canvas> </UserControl>

Technorati Tag: ,,

Related Content