use*_*141 3 c# application-bar pivotitem windows-phone-8
我有一个3 PivotItem秒的应用程序和一个ApplicationBar.我想隐藏ApplicationBar在PivotItem第2和第3选择,并显示ApplicationBar首当PivotItem选择.
我不知道为什么这个问题被投了票.问题意义可能是错误的,可以编辑.我为你找到了解决方案@ user3847141.干得好.
PivotItem pivot = null;
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ApplicationBar appBar = new ApplicationBar();
ApplicationBarIconButton appBarIconButton = new ApplicationBarIconButton();
pivot = (PivotItem)(sender as Pivot).SelectedItem;
switch(pivot.Header.ToString())
{
case "item1":
appBar.Mode = ApplicationBarMode.Default;
appBarIconButton.IconUri = new Uri("/appbar.close.png", UriKind.RelativeOrAbsolute);
appBarIconButton.Text = "Close";
appBar.Buttons.Add(appBarIconButton);
this.ApplicationBar = appBar;
break;
case "item2":
appBar.Mode = ApplicationBarMode.Minimized; // To minimize AppBar
appBar = null; // Delete Application Bar
this.ApplicationBar = appBar;
break;
case "item3":
appBar.Mode = ApplicationBarMode.Minimized;
appBar = null;
this.ApplicationBar = appBar;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
您可以通过Pivot中的Selection_Changed事件来实现此目的.希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
2828 次 |
| 最近记录: |