[Windows ストア アプリ] アプリバーの表示/非表示を切り替える

スポンサーリンク

アプリバーの表示/非表示はコードから操作することが可能です。

アプリバーの表示/非表示はIsOpenプロパティで設定し、Trueにするとアプリバーが表示されます。

下記はコードからアプリバーの表示/非表示を行う例です。

画面に貼り付けられたToggleButtonの状態(押されているかどうか)で、アプリバーの表示/非表示を切り替えます。

アプリバーの表示/非表示を切り替える例

XAMLの例

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<ToggleButton x:Name="ToggleButton1" Content="AppBarの表示/非表示" HorizontalAlignment="Left" Margin="10,644,0,0" VerticalAlignment="Top" Checked="ToggleButton1_Checked"/>
</Grid>
<Page.BottomAppBar>
<AppBar x:Name="bottomAppBar" IsOpen="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource EditAppBarButtonStyle}" Click="Button_Click"/>
<Button Style="{StaticResource RemoveAppBarButtonStyle}" Click="Button_Click"/>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal"/>
</Grid>
</AppBar>
</Page.BottomAppBar>

C#のコード例(ToggleButtonクリック時)

// ToggleButtonチェック時の処理
private void ToggleButton1_Checked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
	bottomAppBar.IsOpen = (bool)ToggleButton1.IsChecked;
}
Please follow and like us:

コメント

タイトルとURLをコピーしました