在VS2010 RTM中使用WPF .NET 4.0:我无法创建全屏WPF弹出窗口.
如果我创建一个大小为50%宽度和100%高度的弹出窗口,一切正常,但如果我尝试创建一个大小为100%宽度和高度的"全屏"弹出窗口,它最终显示为100%宽度和75%高度......底部是截断的.
注意:宽度和高度实际上是以代码中的像素表示的,我使用百分比来使情况更容易理解......
它"感觉"有某种限制,防止弹出区域超过屏幕总面积的约75%.
更新:这是一个显示问题的Hello World示例.
<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 …Run Code Online (Sandbox Code Playgroud) 您无法两次定义窗口的内容,但有没有办法将网格覆盖在另一个网格的顶部?
在我的具体情况下,我正在创建一个国际象棋游戏,我想要一个网格来管理它们的UI和另一个网格来管理黑白方块.我想这样做(而不是使用一个具有不同Z索引的网格),因为在游戏中我想在有效移动的方块上添加不透明矩形.如果我使用单独的网格,我可以通过myGrid.Children.Clear()清理方形UI 来清除矩形,但保留部分.
另一种解决方案是清除特定Z指数的所有儿童.那可能吗?
感谢您的帮助,我可以根据需要发布代码!