在我的Windows Phone 8.1应用页面中更改透视图项目后,我需要更改页面底部的AppBar。我发现的所有示例都与Silverlight Windows Phone 7/8应用程序有关,不适用于通用应用程序Windows Phone 8.1。
<AppBar x:Name="AppBar1" Visibility="Visible">
<CommandBar>
<AppBarButton x:Name="Save" Icon="save" Label="Save" Click="AppBarButton_Click" />
<AppBarButton x:Name="Cancel" Icon="cancel" Label="Cancel" Click="AppBarButton_Click" />
</CommandBar>
</AppBar>
<AppBar x:Name="AppBar2" Visibility="Collapsed">
<CommandBar x:Name="AppBar2">
<AppBarButton x:Name="Add" Icon="save" Label="Add" Click="AppBarButton_Click" />
</CommandBar>
</AppBar>
答案 0 :(得分:1)
<强> XAML 强>
<Pivot x:Name="Pivot" SelectionChanged="Pivot_SelectionChanged">
</Pivot>
<强> C#强>
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int no = Pivot.SelectedIndex;
if(no == 0)
{
AppBar1.Visibility = Visibility.Visible;
AppBar2.Visibility = Visibility.Collapsed;
}
else
{
AppBar1.Visibility = Visibility.Collapsed;
AppBar2.Visibility = Visibility.Visible;
}
}