Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Adorner Layer Outside Window

Tags:

wpf

adorner

I have a WPF window with a textbox control. The control has an adorner that is made visible when the textbox has keyboardfocus.

As you can see in the screenshot below, the adorner is limited to the bounds of the window. How can I make it so that the full adorner is displayed?

enter image description here

Adorner template is:

<DataTemplate x:Key="ContextualInfoDataTemplate">
    <Border 
        Background="#E1E1E1" 
        CornerRadius="6"
        Margin="50,36,0,0">
        <Border.Effect>
            <DropShadowEffect/>
        </Border.Effect>
        <Grid Width="200" Margin="4,3,4,4">
            <TextBlock TextWrapping="Wrap" Text="OverridenAutomationId"/>
        </Grid>
    </Border>
</DataTemplate>
like image 793
David Ward Avatar asked Dec 02 '15 14:12

David Ward


1 Answers

It's not possible. The AdornerLayer confines to the bounds of an AdornerDecorator (the Window has one if you haven't defined one), so it's just not possible to go outside the bounds of that decorator.

You can get what you want using a Popup (MSDN) which defines a popup window, but definitely not using an adorner. Main difference being that the popup is not part of the window's visual tree, so it won't move or resize along with it.

You could also define your own popup window if you want effects that go over the desktop (like the drop shadow you are showing). That'd be indeed tricky, but doable. With a lot of work, you could make it move and resize along with your window too (thus emulating an "out of window adorner"), but that will definitely not be quick or easy to code (for a normal Popup though, you could just hook on your Window's SizeChanged and LocationChanged events and move accordingly)

like image 151
Jcl Avatar answered Dec 01 '22 12:12

Jcl