--- title: "How to: Create a Custom Panel Element" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" - "cpp" helpviewer_keywords: - "Panel control [WPF]" - "custom Panel elements [WPF]" ms.assetid: e0df4f1e-8c07-4e86-89a3-e22acfffdc2a --- # How to: Create a Custom Panel Element ## Example This example shows how to override the default layout behavior of the element and create custom layout elements that are derived from . The example defines a simple custom element called `PlotPanel`, which positions child elements according to two hard-coded x- and y-coordinates. In this example, `x` and `y` are both set to `50`; therefore, all child elements are positioned at that location on the x and y axes. To implement custom behaviors, the example uses the and methods. Each method returns the data that is necessary to position and render child elements. [!code-cpp[PlotPanel#1](~/samples/snippets/cpp/VS_Snippets_Wpf/PlotPanel/CPP/PlotPanel.cpp#1)] [!code-csharp[PlotPanel#1](~/samples/snippets/csharp/VS_Snippets_Wpf/PlotPanel/CSharp/PlotPanel.cs#1)] [!code-vb[PlotPanel#1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PlotPanel/VisualBasic/PlotPanel.vb#1)] ## See also - - [Panels Overview](panels-overview.md)