How do I bind an Adorner to an Element ?

Platform: WPF|Category: Adorners

To bind an adorner to a particular UI element, the following things needs to be done.

  • Call the static method ‘GetAdornerLayer()’, to get the AdornerLayer associated with the UIElement.

  • Call the ‘Add()’ method to bind the Adorner to the target UIElement.

[C#]

        AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
        adornerLayer.Add(new ControlAdorner(myTextBox));