Saturday, June 30, 2007

How to Bind an Adorner to an Element?

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

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

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

Have a fun with WPF programming. Enjoy......!

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

1 comment:

  1. Hi, i have one custom control name as myGrid, which has GridManager as dependency property. actually the owner type ofthis GridManager property is an IGridManager interface, this interface has some more properties such as GridReport,GridSeriesElement etc.

    when i drag a grid it simply showing .
    instead i need to show








    it need to show all child properties in Xaml.

    please Help me.

    ReplyDelete