Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Popup Alternative

Tags:

wpf

popup

I have a window with a popup that pops when an item in a listview is double clicked.
It centers to the main window and looks really nice floating there.
The problem is when the user moves the main window or selects another program, and the popup floats on top of other stuff.

I would like to have something like a popup, meaning that it floats on top of other elements in the window, but sticks with the main window when it moves (stays centered), and doesn't float on top of other programs.
Can I make a popup act like this, or is there a better way to do it?

like image 740
AndyD273 Avatar asked Jul 05 '11 16:07

AndyD273


3 Answers

Popups will not move while the window is resized or moved. Because, Popups/Context menus are not the part of Visual Tree. You have to use Adorner for this. I will suggest to read this four part series for a quick start on Adorner.

like image 92
Amit Avatar answered Nov 07 '22 09:11

Amit


It's possible that an Adorner will fit your needs in this case better than a popup. Adorners can float above your window, too. There are a few differences, mainly that an adorner is bound to a UIElement (which include windows).

like image 35
Ed Bayiates Avatar answered Nov 07 '22 09:11

Ed Bayiates


If you are willing to use a third-party/open source (MS-PL) option, the Extended WPF Toolkit has a ChildWindow control.

It's technically not a separate window, but it appears to be a separate window to the user.

like image 2
Kendrick Avatar answered Nov 07 '22 09:11

Kendrick