wpfinteropadorneradornerlayeradornerdecorator

HwndSource does not display the Adorner layer


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?


Solution

  • 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 };