Hemil
Hemil

Reputation: 1016

Unwanted margin in NavigationView.Content

I made a simple app that does nothing. It inly displays a NavigationView with two items and a TextBlock as its content. This is the code:

<Page
    x:Class="test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:test"
    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>
        <NavigationView>
            <NavigationView.MenuItems>
                <NavigationViewItem Content="First Item" />
                <NavigationViewItem Content="Second Item" />
            </NavigationView.MenuItems>

            <TextBlock Style="{StaticResource HeaderTextBlockStyle}" Text="Welcome to my Page"/>
        </NavigationView>
    </Grid>
</Page>

My app looks like this: Screenshot

Why is there extra space at the top of the TextBlock? And how to remove that space? I know it is possible because the News app uses NavigationView and there is no vertical margin. Here is its screenshot:

News app screenshot

Upvotes: 1

Views: 945

Answers (1)

Michael Hawker - MSFT
Michael Hawker - MSFT

Reputation: 1580

You need to set the AlwaysShowHeader property to False:

<NavigationView AlwaysShowHeader="False">

This is called out in the docs here, though the new preview version seems to change this behavior currently and not show any header by default.

Upvotes: 1

Related Questions