2017-01-25 4 views
0

私は最初のUWPアプリケーションであるアプリを作っています。ポートレートモードを維持するにはコマンドバーが必要ですが、残りのアプリケーションはすべて横長モードになります。ここコマンドバーがランドスケープモードにならないようにする

And in landscape mode, see the bar didn't moved.

in portrait mode

は、これまでの私のコードです:

<Page.BottomAppBar> 
    <CommandBar IsSticky="True" Name="cmdBar_ed"> 
     <CommandBar.PrimaryCommands> 
      <AppBarButton Name="newBtn" Label="" Width="30" Click="newFile"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/test.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
      <AppBarButton Name="newBtn1" Label="" Width="30" Click="newFile"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/test.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
      <AppBarButton Name="newBtn2" Label="" Width="30" Click="newFile"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/test.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
      <AppBarButton Name="newBtn3" Label="" Width="30" Click="newFile"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/test.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
      <AppBarButton Name="newBtn4" Label="" Width="30" Click="newFile"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/test.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
      <AppBarButton Name="btnTab" Label="" Width="30" Click="insertTab"> 
       <AppBarButton.Icon> 
        <BitmapIcon UriSource="ms-appx:///Assets/btnIcon/Tab.png"/> 
       </AppBarButton.Icon> 
      </AppBarButton> 
     </CommandBar.PrimaryCommands> 
     <CommandBar.SecondaryCommands> 
      <AppBarButton Name="btn_save" Icon="Save" Label="Save" Click="save"/> 
      <AppBarButton Name="btn_saveAs" Icon="Save" Label="Save As" Click="saveAs"/> 
      <AppBarButton Name="btnClose" Icon="Cancel" Label="Close File" Click="close" /> 
     </CommandBar.SecondaryCommands> 
    </CommandBar> 
</Page.BottomAppBar> 

また、別の奇妙なことがあり、その画面上のキーボードが起動されると、これを私はこのようなものが必要バーは画面上のキーボードの上に留まり、固定された位置にはありません。修正するにはどうすればいいですか?

+1

あなたはUWPを開発していますか? UWPアプリでは、AppBarアイコンの周りに丸みのあるグリフがないので、これはWindows Phone 8.1アプリケーションのようです。 – schumi1331

+0

はい、私はそれがUWPアプリケーションであると確信しています、私はそれを実行するために私のLumia 435(Windows 10のモバイルにアップグレード)を使用しています。これまでのところ、これらの問題とは別に機能します。 – William

答えて

1

<Page.BottomAppBar/>にコマンドバーを置くと、現在の位置は現在のApplicationViewOrientationに従って変更されますが、それを制御することはできません。

しかし、あなたはパネル(例えば、グリッド)にそれを置く場合:

<Page 
x:Class="AppCommandBar.MainPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:AppCommandBar" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d"> 

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 

    <Grid.RowDefinitions> 
     <RowDefinition Height="9*"></RowDefinition> 
     <RowDefinition Height="*"></RowDefinition> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition></ColumnDefinition> 
     <ColumnDefinition></ColumnDefinition> 
    </Grid.ColumnDefinitions> 
    <CommandBar Name="cmdBar_ed" Grid.Row="1" Grid.ColumnSpan="2"> 
     <CommandBar.PrimaryCommands> 
      <AppBarButton Name="newBtn" Label="test" Width="30"> 
      </AppBarButton> 
     </CommandBar.PrimaryCommands> 
     <CommandBar.SecondaryCommands> 
      <AppBarButton Name="btn_save" Icon="Save" Label="Save"/> 
      <AppBarButton Name="btn_saveAs" Icon="Save" Label="Save As"/> 
      <AppBarButton Name="btnClose" Icon="Cancel" Label="Close File"/> 
     </CommandBar.SecondaryCommands> 
    </CommandBar> 
</Grid> 

をあなたは現在のビューの向きを検出する方法を現在のビューのorientation.Aboutことによって、その位置を手動で設定することができ、ご確認ください。このスレッドHow to detect orientation changes and change layout

+0

私はそれを調べましたが、私はまだその位置にグリッドをロックする方法を理解していない、何とか、この男[ここ](http://stackoverflow.com/questions/30767273/how-to-get-the-デバイスの向きが変更されたイベント - ウィンドウ - 電話)は、画像を見ましたか? – William

+1

@ウィリアム私は、グリッドの位置を固定しないで、コマンドバーの位置をグリッド(例:行、列)に変更することを意味しました。 'Grid.SetColumn'と' Grid.SetRow'を使ってComamndbarの位置を違う方向に変更できます。垂直方向に表示するにはカスタム[コマンドバーのスタイル](https://msdn.microsoft.com/en-us/library/windows/apps/mt299118.aspx)が必要です。 –

関連する問題