在 Panorama 页面中添加 ApplicationBar

   因为默认在 Panorama 控件中,是不推荐使用 ApplicationBar 的,经过探索,研究了如下方法,并在 Panorama 控件需要的 Item

中显示 ApplicationBar:

       ApplicationBar appBar;
ApplicationBarIconButton btnAppBarRefresh;
ApplicationBarIconButton btnAppBarSearch;
ApplicationBarMenuItem menuItem1;
ApplicationBarMenuItem menuItem2;


#region ApplicationBar
appBar = new ApplicationBar();
appBar.Mode = ApplicationBarMode.Default;
appBar.Opacity = 0.5;
appBar.IsVisible = true;
appBar.IsMenuEnabled = true;

btnAppBarRefresh = new ApplicationBarIconButton();
btnAppBarRefresh.IsEnabled = false;
btnAppBarRefresh.IconUri = new Uri("/Icons/appbar.refresh.rest.png", UriKind.Relative);
btnAppBarRefresh.Text = "Refresh";
btnAppBarRefresh.Click += new EventHandler(btnAppBarRefresh_Click);
appBar.Buttons.Add(btnAppBarRefresh);

btnAppBarSearch = new ApplicationBarIconButton();
btnAppBarSearch.IconUri = new Uri("/Icons/appbar.feature.search.rest.png", UriKind.Relative);
btnAppBarSearch.Text = "Search";
btnAppBarSearch.Click += new EventHandler(btnAppBarSearch_Click);
appBar.Buttons.Add(btnAppBarSearch);

menuItem1 = new ApplicationBarMenuItem();
menuItem1.Text = "Refresh";

menuItem2 = new ApplicationBarMenuItem();
menuItem2.Text = "Search";

appBar.MenuItems.Add(menuItem1);
appBar.MenuItems.Add(menuItem2);
#endregion

调用:

 private void Panorama_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (panorama_mainpage.SelectedIndex == 1 || panorama_mainpage.SelectedIndex == 2)
{
this.ApplicationBar = appBar;
}
else
{
this.ApplicationBar = null;
}
}




你可能感兴趣的:(application)