* 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
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 |
|
|
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:
-
Call the
staticmethod 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.) -
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.