Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP show Fullscreen Popup, ContentDialog or Flyout

I need to display a full screen dialog (in application window boundaries) in my UWP application, but can't seems to make it work. I tried with :

  • ContentDialog only shows vertically stretched with FullSizeDesired="True"

  • Popup, even trying to set the width and height in code behind its not working

  • Flyout Placement="Full" only stretch it vertically just like the contentdialog

Can't believe I spend so much time on that thing :(

Thanks

like image 512
danbord Avatar asked Oct 29 '22 00:10

danbord


1 Answers

Have you tried something like this:

var c = Window.Current.Bounds;
var g = new Grid
{
    Width = c.Width,
    Height = c.Height,
    Background = new SolidColorBrush(Color.FromArgb(0x20, 0, 0, 0)),
    Children =
    {
        new Rectangle
        {
            Width = 100,
            Height = 100,
            Fill = new SolidColorBrush(Colors.White),
            Stroke = new SolidColorBrush(Colors.Black),
            StrokeThickness = 3
        }
    }
};
var p = new Popup
{
    HorizontalOffset = 0,
    VerticalOffset = 0,
    Width = c.Width,
    Height = c.Height,
    Child = g
};

p.IsOpen = true; // open when ready

You should see a semi-transparent overlay with a white rectangle in the middle of your screen.

like image 90
Laith Avatar answered Nov 15 '22 04:11

Laith