Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I overlay a control on a window?

Tags:

wpf

Right now I have a normal window with a bunch of controls.

When the user hits a certain button I want to dim the entire window and then display a popup on top of it. Not a true dialog box, just something that is inside the window.

So this is my theory...

  1. Every control is on layer 0.
  2. There is a rectangle the same size as the form in layer 1. This has 50% transparency.
  3. My popup is loaded into layer 2.
  4. Clicking anywhere on the rectangle will do the same thing as pressing close on the pop-up.

Is this possible?

like image 854
Jonathan Allen Avatar asked Jul 18 '10 13:07

Jonathan Allen


People also ask

What is window control overlay?

The Window Controls Overlay API gives Progressive Web Apps installed on desktop operating systems the ability to hide the default window title bar and display their own content over the full surface area of the app window, turning the control buttons (maximize, minimize, and close) into an overlay.

How do I enable the title bar in edge?

Right on the top-left corner of the Edge window and select the “Show title bar” option to show the title bar. This will make the Edge browser show the title bar when using Vertical Tabs.


1 Answers

This is perfectly possible.

Put your entire UI in any panel inside of a <Grid>.

Then, in the same grid, put a <Rectangle Opacity=".5" Visibility="Collapsed" /> for the overlay and a centered panel for the popup.

Handle the rectangle's click event and hide the popup.

like image 193
SLaks Avatar answered Sep 23 '22 19:09

SLaks