Prevent Application Bar from scrolling up Layout

坚强是说给别人听的谎言 提交于 2020-01-06 15:31:36

问题


I am building a windows phone 8 application with an ApplicationBar to keep the shortcuts and some menu options for the application. I read somewhere that that Height for ApplicationBar is 72px. So I tried with this code

<Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="72"></RowDefinition>
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Row="0" Name="scrollViewer" Width="Auto" VerticalAlignment="Top" >
            <Grid x:Name="ContentPanel" Background="DarkSeaGreen">
                <TextBlock Name="tb" FontSize="100" TextWrapping="Wrap"
                       Text="Hello eveyone. Need some help with AppBar">
                </TextBlock>
        </Grid>
        </ScrollViewer>
</Grid>

I was expecting the ApplicationBar to fit in space provided in the Grid and not to scroll up my layout. But what happened is this. http://i.stack.imgur.com/cjEXD.png

ApplicationBar pushed up the Layout leaving a blank space. I wish to prevent this thing. I want my Application Bar to be visible but it should not scroll up my layout. Please help if you know of any kind of solution to this.

Thanks


回答1:


You can achieve this by setting the Opacity of your ApplicationBar to a value < 1. Then it overlays your layout and does not push it up. In my eyes Opacity="0.99" is a good option.

But be careful: The ApplicationBar's height is not always 72px. On a 1080p device for example it differs!

To determine the actual height of your Application Bar you can use ApplicationBar.DefaultSize or respectively ApplicationBar.MiniSize.

For more information the the MSDN documentation.



来源:https://stackoverflow.com/questions/23339018/prevent-application-bar-from-scrolling-up-layout

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