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

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

> ContentDialog仅显示使用FullSizeDesired =“True”进行垂直拉伸
> Popup,甚至试图在代码后面设置宽度和高度不起作用
> Flyout Placement =“Full”只能像contentdialog那样垂直拉伸

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

谢谢

解决方法:

你尝试过这样的事情:

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

您应该会看到一个半透明的叠加层,屏幕中间有一个白色矩形.

上一篇:c# – 如何从不同来源同步播放视频和音频?


下一篇:c# – UWP后台任务错误