Class Canvas
Defines an area within which you can explicitly position child objects, using coordinates that are relative to the Canvas area.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
public class Canvas : Panel
Examples
You can add a Canvas to the XAML as follows:
Or in C#:
Canvas myCanvas = new Canvas();
myCanvas.Width = 100;
myCanvas.Height = 100;
myCanvas.Background = new SolidColorBrush(Windows.UI.Colors.Blue);
myCanvas.HorizontalAlignment=HorizontalAlignment.Left;
Fields
| Improve this Doc View SourceLeftProperty
Identifies the Canvas.Left attached property.
Declaration
public static readonly DependencyProperty LeftProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
TopProperty
Identifies the Canvas.Top attached property.
Declaration
public static readonly DependencyProperty TopProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ZIndexProperty
Identifies the Canvas.ZIndex attached property.
Declaration
public static readonly DependencyProperty ZIndexProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Methods
| Improve this Doc View SourceArrangeOverride(Size)
Declaration
protected override Size ArrangeOverride(Size finalSize)
Parameters
Type | Name | Description |
---|---|---|
Size | finalSize |
Returns
Type | Description |
---|---|
Size |
Overrides
| Improve this Doc View SourceCreateDomElement(Object, out Object)
Declaration
public override object CreateDomElement(object parentRef, out object domElementWhereToPlaceChildren)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parentRef | |
System.Object | domElementWhereToPlaceChildren |
Returns
Type | Description |
---|---|
System.Object |
Overrides
| Improve this Doc View SourceGetLeft(UIElement)
Gets the value of the Canvas.Left XAML attached property for the target element.
Declaration
public static double GetLeft(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object from which the property value is read. |
Returns
Type | Description |
---|---|
System.Double | The Canvas.Left XAML attached property value of the specified object. |
GetTop(UIElement)
Gets the value of the Canvas.Top XAML attached property for the target element.
Declaration
public static double GetTop(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object from which the property value is read. |
Returns
Type | Description |
---|---|
System.Double | The Canvas.Top XAML attached property value of the specified object. |
GetZIndex(UIElement)
Gets the value of the Canvas.ZIndex XAML attached property for the target element.
Declaration
public static int GetZIndex(UIElement element)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object from which the property value is read. |
Returns
Type | Description |
---|---|
System.Int32 | The Canvas.ZIndex XAML attached property value of the specified object. |
MeasureOverride(Size)
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
Size | availableSize |
Returns
Type | Description |
---|---|
Size |
Overrides
| Improve this Doc View SourceSetLeft(UIElement, Double)
Sets the value of the Canvas.Left XAML attached property for a target element.
Declaration
public static void SetLeft(UIElement element, double value)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object to which the property value is written. |
System.Double | value | The value to set. |
SetTop(UIElement, Double)
Sets the value of the Canvas.Top XAML attached property for a target element.
Declaration
public static void SetTop(UIElement element, double value)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object to which the property value is written. |
System.Double | value | The value to set. |
SetZIndex(UIElement, Int32)
Sets the value of the Canvas.ZIndex XAML attached property for a target element.
Declaration
public static void SetZIndex(UIElement element, int value)
Parameters
Type | Name | Description |
---|---|---|
UIElement | element | The object to which the property value is written. |
System.Int32 | value | The value to set. |