Defines an area within which you can explicitly position child elements by using coordinates that are relative to the area.
To create an object using scripting, see the CreateFromXAML method.
|oneOrMoreUIElements||One or more object elements that derive from UIElement. These can be one or more of the following: Canvas, Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle, Shape, TextBlock. Object elements defined here become members of the collection held by the Children property, when accessed by scripting at runtime.|
Background, Canvas.Left, Canvas.Top, Canvas.ZIndex, Children, Clip, Cursor, Height, IsHitTestVisible, Name, Opacity, OpacityMask, RenderTransform, RenderTransformOrigin, Resources, Tag, Triggers, Visibility, Width
In Silverlight 1.0, a Canvas is typically the root element for the XAML that is the Source of a Silverlight plug-in.
A Canvas can contain child elements. These child elements are rendered within the Canvas area. Each child element must be a UIElement. In XAML, you declare child elements by declaring them as object elements that are the inner XML of a Canvas object element. This is an example of a XAML content property syntax; see XAML Syntax Overview for more information about XAML syntax and its terminology. In script, you can manipulate the collection of Canvas child objects by getting the collection that is accessed by the Children property.
You can nest Canvas elements, because a Canvas is a type of UIElement.
In many cases, a Canvas object is used solely as a container for other objects and does not have any visible properties. A Canvas object is not visible if one or more of the following conditions are true:
- The Height property is equal to 0.
- The Width property is equal to 0.
- The Background property is equal to null.
- The Opacity property is equal to 0.
- The Visibility property is equal to Collapsed.
- One of the ancestors of the Canvas object is not visible.
In Silverlight 1.0, keyboard events are only available to the root element. Canvas is the typical root element. Only Canvas supports KeyDown and KeyUp, and only the Canvas at the root can attach handlers for these events. InkPresenter, although similar to Canvas in other respects, cannot have attached handlers for KeyDown and KeyUp events. You must process all key events from the perspective that the sender of the event arguments is always the root element.
GotFocus and LostFocus events have similar restrictions. Handlers for these events can only be attached on the root element. In this case, the root element does not need to be a Canvas, but root elements other than a Canvas are uncommon.