Search code examples
c#wpfwindows-store-appspixelsenseappbar

Why AppBar behaviors differently in windows surface pro 1 and windows surface pro 4?


I have my app bar defined as below:

<AppBar x:Name="MyBottomBar" IsSticky="True" IsOpen="True" Closed="MyBottomBar_Closed" SizeChanged="MyBottomBar_SizeChanged">

private void MyBottomBar_Closed(object sender, object e)
{
  if (!this.BottomAppBar.IsOpen && KeepBottomAppBarOpen)
  {
      this.BottomAppBar.IsOpen = true;
  }
}

Then I have a TextBox at the top of the same page as the app bar, once I start to type in the text box, the soft keyboard displays. I have some workflows to set the KeepBottomAppBarOpen to true. But when I type in the text box, KeepBottomAppBarOpen is false. In surface pro 1, once I start to type in the text box, the soft keyboard displays and the app bar jumps above the soft keyboard. But in surface pro 4, once I start to type in the text box, the soft keyboard displays and the app bar doesn't jump and because it is at the bottom of the page, the soft keyboard will hide it.

Is this by design due to the difference between surface pro 1 and surface pro 4?
What can I do so that the app bar doesn't jump above the soft keyboard in surface pro 1?

Add screens. Surface Pro 1: enter image description here

Surface Pro 4: enter image description here


Solution

  • Personally I think it is by design. And if you don't want the bar to jump over the soft keyboard, you can refer to what Amy said in this thread.

    when we tap on the TextBoxs, the BottomAppBar will stuck to the top of the onscreen keyboard, the solution is to put the AppBar inside the Grid instead of the BottonAppBar.

    <Grid>
        <AppBarButton VerticalAlignment="Bottom">
           <TextBox Text="AppBar"/>
        </AppBarButton>
        <TextBox VerticalAlignment="Center" Text="Hola"/>
    </Grid>
    

    I have tested it and it works ok. Hope it will be helpful.