【问题标题】:Grid control can't cover the whole page and leaves a space at the top网格控件无法覆盖整个页面并在顶部留出空间
【发布时间】:2015-11-14 14:57:31
【问题描述】:

我在 xaml 中定义了一个默认网格控件:

<Page
    x:Class="App.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>

    </Grid>
</Page>

而且这个网格不是从页面顶部开始的,如下图所示:

实现此目的的一种方法是设置负边距,如下所示:

<Page
    x:Class="App.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid Margin="0,-26.667,0,0">

    </Grid>
</Page>

所以它看起来像这张照片:

不过,我看过 Bob Tabor 的一些视频,例如 this one,他的所有默认控件都是从页面顶部开始的。

这里有什么问题,在不设置负边距的情况下如何解决?

【问题讨论】:

    标签: c# xaml windows-phone-8.1


    【解决方案1】:

    默认情况下有状态栏。 您有 2 个选择:

    1. 隐藏 -> Hide Status bar in Windows Phone 8.1 Universal Apps

    2. 把你的内容放在下面:

    var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);

    您可能希望阅读此内容以获取更多信息: http://blogs.msdn.com/b/amar/archive/2014/05/12/status-bar-in-windows-phone-8-1.aspx

    【讨论】:

    • 我会将其标记为答案,尽管它不是一个优雅的解决方案。我必须从后面的代码中隐藏状态栏,所以我不知道在设计应用程序的过程中整体设计会是什么样子。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 2019-08-09
    • 1970-01-01
    • 2012-08-20
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多