Windows Phone Pivot 显示在应有的上方 [英] Windows Phone Pivot Displaying above where it should

查看:20
本文介绍了Windows Phone Pivot 显示在应有的上方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 xaml

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel Orientation="Horizontal">
        <Frame Height="Auto" Width="200" Background="Green" />
    </StackPanel>
    <Pivot Grid.Row="1" Background="Red" Width="200" VerticalAlignment="Stretch" Title="Pivot Title">
        <PivotItem Header="Blah">
            <TextBlock Text="Pivot content"/>
        </PivotItem>
    </Pivot>
</Grid>

产生以下布局

问题是支点出现在我认为它在逻辑上应该出现的上方.枢轴应出现在中间标记下方,但它出现在其上方约 27 像素处.我当然可以只在枢轴上添加一个顶部边距以将其向下推,但我想了解为什么它首先出现在那里.

The issue is that the pivot is appearing above where I would think it logically should appear. The pivot should appear below the half way mark but instead it is appearing about 27 pixels above it. I can of course just add a top margin to the pivot to push it back down but I'd like to get to the bottom of why it's appearing up there in the first place.

推荐答案

导致该问题的原因是 Pivotvertical margin 取决于状态栏,因为 Pivot 旨在成为页面的唯一子元素.如果您的边界模式设置为 UseVisible 并且您的状态栏可见,那么 pivot 的垂直边距将为负(大约 -20,我认为).因此,如果您将此代码添加到构造函数中:

The cause of that problem is that vertical margin of Pivot depends on bounds mode of status bar, as Pivot is intented to be the only child element of a page. If your bounds mode is set to UseVisible and your status bar is visible, then pivot's vertical margin will be negative (about -20, I think). So, if you add this code to the constructor:

ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

根本没有垂直边距,您将得到预期的行为:

There'll be no vertical margin at all, and you will have expected behavior:

这篇关于Windows Phone Pivot 显示在应有的上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆