UWP显示全屏弹出窗口,ContentDialog或弹出窗口 [英] UWP show Fullscreen Popup, ContentDialog or Flyout

查看:276
本文介绍了UWP显示全屏弹出窗口,ContentDialog或弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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仅显示使用FullSizeDesired ="True"

  • 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"仅像contentdialog一样垂直拉伸

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

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

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

谢谢

推荐答案

您是否尝试过以下方法:

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.

这篇关于UWP显示全屏弹出窗口,ContentDialog或弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆