首页 文章

XAML Hub Control Windows 8.1 Universal app

提问于
浏览
2

为什么Windows 8.1中的集线器控件看起来像是在顶部增加了120像素?

我嵌套了我的Hub控件,如下所示:

<Grid Background="{StaticResource DmWhiteBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <controls:TopNavigationBarControl Grid.Row="0" />

        <Hub
            Grid.Row="1"
            Margin="0"
            VerticalContentAlignment="Stretch"                 >
            <HubSection
                VerticalContentAlignment="Stretch" > DATA BLA BLA
            </HubSection>

在我的集线器和我的控件之间:TopNavigationBarControl似乎有大约120个额外像素,我发现没有什么比在hub元素上添加负上边距更好,但那不是很好 . 有没有人知道我可以做些什么来消除这个?我不想在hub元素中使用 Headers . 谢谢!

编辑:截至目前,我发现没有什么比编辑集线器的模板更好,并删除 Headers ,并使用混合删除顶部填充 . 另外在我添加的hub元素上

<Hub
    Grid.Row="0"
    Grid.RowSpan="2"
    Margin="0">

编辑2:在混合中我无法找到那些额外的像素!我可以清楚地看到,仍然有一个 Headers 的空间,甚至认为我已经删除了混合中的网格行定义 .

1 回答

  • 4

    您还需要为每个 HubSection 删除 Padding .

    这是 HubSection conrol的默认填充 .

    <Setter Property="Padding" Value="40,40,40,44"/>
    

    将第二个 40 更改为 0 将折叠其间的所有空间 .

    <HubSection Header="HubSection 0" Padding="40,0,40,44">
    

    Update

    这是代码以及它在设计器上的样子 . 当我运行它时它看起来完全一样 .

    enter image description here

    enter image description here

相关问题