AdornerLayer.Add Method

Adds an adorner to the adorner layer.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public void Add(
	Adorner adorner
)
You cannot use methods in XAML.

Parameters

adorner
Type: System.Windows.Documents.Adorner

The adorner to add.

ExceptionCondition
ArgumentNullException

Raised when adorner is null.

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));
NoteNote:

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

More Code

How to: Adorn the Children of a Panel This example shows how to programmatically bind an adorner to the children of a specified Panel.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft