How to: Adorn the Children of a Panel

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

Example

To bind an adorner to the children of a Panel, follow these steps:

 

  1. Declare a new AdornerLayer object and call the static GetAdornerLayer method to find an adorner layer for the element whose children are to be adorned.

  2. Enumerate through the children of the parent element and call the Add method to bind an adorner to each child element.

The following example binds a SimpleCircleAdorner (shown above) to the children of a StackPanel named myStackPanel.

For Each toAdorn As UIElement In myStackPanel.Children
    myAdornerLayer.Add(New SimpleCircleAdorner(toAdorn))
Next
foreach (UIElement toAdorn in myStackPanel.Children)
  myAdornerLayer.Add(new SimpleCircleAdorner(toAdorn));

Note

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

See Also

Tasks

SimpleCircleAdorner Sample

Add and Remove Adorners Sample

SimpleCircleAdorner Sample

Concepts

Adorners Overview