Search code examples
wpfwpf-controlsadorner

GetAdornerLayer() for a control derived from MedialElementBase


I have a WPF control which is derived from MedialElementBase(Base class is UIElement). This control is used to dislay video from webcam. I need to draw lines on this video. I am using WPF Adorners and calling GetAdornerLayer() for above control which always returns NULL. Am I using this correctly? Any idea why this is happening?


Solution

  • An AdornerLayer is created by an AdornerDecorator or a ScrollContentPresenter in the visual tree. By default the ControlTemplate for Window has one surrounding all its content. If there is neither an AdornerDecorator or ScrollContentPresenter as a parent to your control, it will return null.