无法创建一个全屏的WPF弹出 [英] Can't create a fullscreen WPF popup

查看:103
本文介绍了无法创建一个全屏的WPF弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2010 RTM使用WPF .NET 4.0。我不能创建一个全屏WPF弹出

Using WPF .NET 4.0 in VS2010 RTM: I can't create a fullscreen WPF popup.

如果我创建一个大小50%的宽度和100%的高度一切正常弹出,但如果我尝试创建一个全屏幕弹出大小,以100%的宽度和高度它最终显示在100%的宽度和75%的高度...底部被截断。

If I create a popup that is sized 50% width and 100% height everything works fine, but if I try to create a "full screen" popup sized to 100% width and height it ends up displaying at 100% width and 75% height... the bottom is truncated.

注:宽度和高度实际上是pssed在code像素EX $ P $,我用百分比来使情况多一点理解...

Note: The width and height are actually being expressed in pixels in code, I'm using percent to make the situation a little more understandable...

感觉好像有上限$ P $的某种超出屏幕总面积的〜75%pventing弹出的区域。

It "feels" like there is some sort of limit preventing the area of a popup from exceeding ~75% of the total area of the screen.

更新:这是一个Hello World的例子,显示了问题。

UPDATE: Here is a Hello World example that shows the problem.

<Window x:Class="TechnologyVisualizer.PopupTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="PopupTest" 
        WindowStyle="None" WindowState="Maximized" Background="DarkGray">
    <Canvas x:Name="MainCanvas" Width="1920" Height="1080">
        <Popup Placement="Center" VerticalAlignment="Center" HorizontalAlignment="Center" Width="1900" Height="1060" Name="popContent">
            <TextBlock Background="Red">Hello World</TextBlock>
        </Popup>
        <Button Canvas.Left="50" Canvas.Top="50" Content="Menu" Height="60" Name="button1" Width="80"
                 FontSize="22" Foreground="White" Background="Black" Click="button1_Click" />
    </Canvas>
</Window>




 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TechnologyVisualizer
{
    /// <summary>
    /// Interaction logic for PopupTest.xaml
    /// </summary>
    public partial class PopupTest : Window
    {
        public PopupTest()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            popContent.IsOpen = true;
        }

    }
}

如果您运行这个弹出窗口底部的25%,如果你改变弹出500的宽度,那么它会去全高度丢失

If you run this the bottom 25% of the popup is missing if you change the width of the popup to 500 then it will go full height

推荐答案

您猜对了尺寸限制(在屏幕的75%)是正确的。它的记录在这里:

Your guess about the size limitation (75% of the screen) is correct. It's documented here:

<一个href="http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.placementmode%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.placementmode%28VS.85%29.aspx

相关说明是从.NET 4文档丢失。我认为你需要使用获得全屏幕的另一种方法。我通常使用最大化,无国界的,不可调整大小的窗口。

The relevant note is missing from the .NET 4 docs. I think you'll need to use another method of getting full screen. I normally use a maximized, borderless, non-resizable window.

这篇关于无法创建一个全屏的WPF弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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