Cette documentation est archivée et n’est pas conservée.

AdornerLayer.Add, méthode

Adds an adorner to the adorner layer.

Espace de noms: System.Windows.Documents
Assembly : PresentationFramework (dans presentationframework.dll)

public void Add (
	Adorner adorner
public void Add (
	Adorner adorner
public function Add (
	adorner : Adorner
Vous ne pouvez pas utiliser des méthodes dans XAML.



The adorner to add.

Type d'exceptionCondition


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

RemarqueRemarque :

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

Davantage de 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.

Microsoft .NET Framework 3.0 est pris en charge sur Windows Vista, Microsoft Windows XP SP2 et Windows Server 2003 SP1.

.NET Framework

Prise en charge dans : 3.0