HwndSource does not display the Adorner layer

775 views Asked by At

When I host WPF controls that use adorners (the error border of the textbox) in a HwndSource the adorners are not shown. It seems that the adorner layer is not there. Why is that so and what can I do against it? Is this a known bug?

1

There are 1 answers

0
Daniel On BEST ANSWER

The AdornerLayer is usually part of the default template of the Window class.

If you are customizing the Window template or host controls in something else than a Window; you'll have to create the AdornerLayer yourself.

This can be done by wrapping your WPF controls inside a System.Windows.Documents.AdornerDecorator:

hwndSource.RootVisual = new AdornerDecorator { Child = yourTextBox };