Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-create-a-custom-panel-element.md
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.5 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Create a Custom Panel Element 03/30/2017
csharp
vb
cpp
Panel control [WPF]
custom Panel elements [WPF]
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 xref:System.Windows.Controls.Panel element and create custom layout elements that are derived from xref:System.Windows.Controls.Panel.

The example defines a simple custom xref:System.Windows.Controls.Panel 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 xref:System.Windows.Controls.Panel behaviors, the example uses the xref:System.Windows.FrameworkElement.MeasureOverride%2A and xref:System.Windows.FrameworkElement.ArrangeOverride%2A methods. Each method returns the xref:System.Windows.Size data that is necessary to position and render child elements.

[!code-cppPlotPanel#1] [!code-csharpPlotPanel#1] [!code-vbPlotPanel#1]

See also