--- title: "How to: Get or Set Canvas Positioning Properties" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "Canvas control [WPF], setting positioning properties" ms.assetid: 1636b950-2b5a-4507-8a10-c5034cc58b1c --- # How to: Get or Set Canvas Positioning Properties This example shows how to use the positioning methods of the element to position child content. This example uses content in a to represent positioning values and converts the values into instances of , which is a required argument for positioning. The values are then converted back into strings and displayed as text in a element by using the method. ## Example The following example creates a element that has eleven selectable elements. The event triggers the `ChangeLeft` custom method, which the subsequent code block defines. Each represents a value, which is one of the arguments that the method of accepts. In order to use a to represent an instance of , you must first convert the to the correct data type. [!code-xaml[CanvasPositioningProperties#1](~/samples/snippets/csharp/VS_Snippets_Wpf/CanvasPositioningProperties/CSharp/Window1.xaml#1)] When a user changes the selection, it invokes the `ChangeLeft` custom method. This method passes the to a object, which converts the of a to an instance of (notice that this value has already been converted to a by using the method). This value is then passed back to the and methods of in order to change the position of the `text1` object. [!code-csharp[CanvasPositioningProperties#2](~/samples/snippets/csharp/VS_Snippets_Wpf/CanvasPositioningProperties/CSharp/Window1.xaml.cs#2)] [!code-vb[CanvasPositioningProperties#2](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CanvasPositioningProperties/VisualBasic/Window1.xaml.vb#2)] ## See also - - - - [Panels Overview](panels-overview.md)