Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-create-and-use-a-canvas.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

1.7 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Create and Use a Canvas 03/30/2017
csharp
vb
controls [WPF], Canvas
Canvas control [WPF], creating
Canvas control [WPF], using
420b9487-9a15-477c-9489-a22a4dec7779

How to: Create and Use a Canvas

This example shows how to create and use an instance of xref:System.Windows.Controls.Canvas.

Example

The following example explicitly positions two xref:System.Windows.Controls.TextBlock elements by using the xref:System.Windows.Controls.Canvas.SetTop%2A and xref:System.Windows.Controls.Canvas.SetLeft%2A methods of xref:System.Windows.Controls.Canvas. The example also assigns a xref:System.Windows.Controls.Control.Background%2A color of LightSteelBlue to the xref:System.Windows.Controls.Canvas.

Note

When you use Extensible Application Markup Language (XAML) to position xref:System.Windows.Controls.TextBlock elements, use the xref:System.Windows.Controls.Canvas.Top%2A and xref:System.Windows.Controls.Canvas.Left%2A properties.

[!code-csharpCanvasCode#1] [!code-vbCanvasCode#1]

See also