Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-bind-an-adorner-to-an-element.md
T
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.8 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Bind an Adorner to an Element 03/30/2017
csharp
vb
UIElements [WPF], binding adorners to
adorners [WPF], binding to specified UIElements
b2101611-a0ee-4137-bdb8-9b3673d2e6b9

How to: Bind an Adorner to an Element

This example shows how to programmatically bind an adorner to a specified xref:System.Windows.UIElement.

Example

To bind an adorner to a particular xref:System.Windows.UIElement, follow these steps:

  1. Call the static method xref:System.Windows.Documents.AdornerLayer.GetAdornerLayer%2A to get an xref:System.Windows.Documents.AdornerLayer object for the xref:System.Windows.UIElement to be adorned. xref:System.Windows.Documents.AdornerLayer.GetAdornerLayer%2A walks up the visual tree, starting at the specified UIElement, and returns the first adorner layer it finds. (If no adorner layers are found, the method returns null.)

  2. Call the xref:System.Windows.Documents.AdornerLayer.Add%2A method to bind the adorner to the target UIElement.

The following example binds a SimpleCircleAdorner (shown above) to a xref:System.Windows.Controls.TextBox named myTextBox.

[!code-csharpAdorners_SimpleCircleAdorner#_AdornSingleElement] [!code-vbAdorners_SimpleCircleAdorner#_AdornSingleElement]

Note

Using [!INCLUDETLA#tla_xaml] to bind an adorner to another element is currently not supported.

See also