Windows Phone Pivot Displaying above where it should

爱⌒轻易说出口 提交于 2019-12-22 14:55:26

问题


I have the following 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>

Which produces the following layout

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.


回答1:


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:



来源:https://stackoverflow.com/questions/25678324/windows-phone-pivot-displaying-above-where-it-should

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!