--- title: "How to: Use the Attached Properties of Canvas to Position Child Elements" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "attached properties [WPF Designer]" - "Canvas control [WPF], attached properties" ms.assetid: 48f1d25d-3820-4107-a4cc-d6c1e5664a44 --- # How to: Use the Attached Properties of Canvas to Position Child Elements This example shows how to use the attached properties of to position child elements. ## Example The following example adds four elements as child elements of a parent . Each element is represented by a , , , and . Each is positioned relative to the parent and according to its assigned property value. [!code-cpp[CanvasAttachedProperties#1](~/samples/snippets/cpp/VS_Snippets_Wpf/CanvasAttachedProperties/CPP/CanvasAttachedProps.cpp#1)] [!code-csharp[CanvasAttachedProperties#1](~/samples/snippets/csharp/VS_Snippets_Wpf/CanvasAttachedProperties/CSharp/CanvasAttachedProps.cs#1)] [!code-vb[CanvasAttachedProperties#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CanvasAttachedProperties/VisualBasic/CanvasAttachedProps.vb#1)] ## See also - - - - - - - [Panels Overview](panels-overview.md) - [How-to Topics](canvas-how-to-topics.md) - [Attached Properties Overview](../advanced/attached-properties-overview.md)