Windows Phone 8 弹出窗口的宽度和高度 [英] windows phone 8 popup width and height
问题描述
我在弹出控件中放置了一个网格.我希望根据 Windows Phone 8 应用程序的 3 种不同布局大小(480 × 800、768 × 1280、720 × 1280)自动调整网格大小.
I am placing a grid in a popup control. I expected the grid to be re-sized automatically according to the 3 different layout sizes for windows phone 8 apps (480 × 800, 768 × 1280, 720 × 1280).
但似乎我必须显式设置网格的宽度和高度,因为它根据子控件大小调整自身大小,而我想要弹出窗口框在所有三种分辨率的屏幕顶部显示为完整.
But it seems like i would have to set the width and height of the grid explicitly because it's re-sizing itself according to child control size whereas i wanted the popup box to be shown as full with on the top of the screen for all three resolutions.
有什么帮助吗?
推荐答案
让全屏弹出窗口在 WP8 上工作的最简单方法是设置子宽度 &高度为手机当前的逻辑分辨率.您可以在此处阅读有关 WP8 Multi-resolution zen 的更多信息,并了解有关 WP8 多分辨率 API 在这里.
The easiest way to get a full screen popup to work on WP8 is by setting the Child width & height to the phone's current logical resolution. You can read more about WP8 Multi-resolution zen here and learn more about WP8 Multi-resolution APIs here.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var myPopup = new Popup()
{
Child = new Border()
{
Child = new TextBlock()
{
Text = "Hello World!"
},
Height = Application.Current.Host.Content.ActualHeight,
Width = Application.Current.Host.Content.ActualWidth,
Background = new SolidColorBrush(Colors.Green)
}
};
this.LayoutRoot.Children.Add(myPopup);
myPopup.IsOpen = true;
}
此代码片段有点过分热情,因为外壳项目(例如 SystemTray、AplicaitonBar 等)可能会占用渲染区域的空间.
This code snippet is a bit overzealous since shell items (e.g. SystemTray, AplicaitonBar, etc) can take space away from your rendering area.
这是在 WXGA 模拟器中执行的上述代码片段的打印屏幕:
Here's a print screen of the code snippet above executing in the WXGA emulator:
这是上面在 720P 模拟器中执行的代码片段:
And here's the code snippet above executing in the 720P emulator:
这篇关于Windows Phone 8 弹出窗口的宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!