This topic has not yet been rated - Rate this topic

AdornerLayer.GetAdornerLayer Method

Returns the first adorner layer in the visual tree above a specified Visual.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
public static AdornerLayer GetAdornerLayer(
	Visual visual
)

Parameters

visual
Type: System.Windows.Media.Visual
The visual element for which to find an adorner layer.

Return Value

Type: System.Windows.Documents.AdornerLayer
An adorner layer for the specified visual, or null if no adorner layer can be found.
Exception Condition
ArgumentNullException

Raised when visual is null.

This static method traverses up the visual tree starting at the specified Visual and returns the first adorner layer found.

This example shows how to programmatically bind an adorner to a specified UIElement.

To bind an adorner to a particular UIElement, follow these steps:

 

  1. Call the static method GetAdornerLayer to get an AdornerLayer object for the UIElement to be adorned. GetAdornerLayer 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 Add method to bind the adorner to the target UIElement.

The following example binds a SimpleCircleAdorner (shown above) to a TextBox named myTextBox.


myAdornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
myAdornerLayer.Add(new SimpleCircleAdorner(myTextBox));


Note Note

Using Extensible Application Markup Language (XAML) to bind an adorner to another element is currently not supported.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ