UWP显示全屏弹出窗口,ContentDialog或弹出

dan*_*ord 5 c# xaml fullscreen uwp

我需要在UWP应用程序中显示一个全屏对话框(在应用程序窗口的边界),但似乎无法正常工作。我尝试了:

  • ContentDialog仅显示使用FullSizeDesired =“ True”垂直拉伸

  • 弹出窗口,甚至试图在其后面的代码中设置宽度和高度

  • Flyout Placement =“ Full”仅像contentdialog一样垂直拉伸

不敢相信我在这件事上花了很多时间:(

谢谢

Lai*_*ith 1

你有没有尝试过这样的事情:

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
Run Code Online (Sandbox Code Playgroud)

您应该在屏幕中间看到一个半透明的覆盖层,其中有一个白色矩形。