I am developing an application for windows phone 8. My problem is I could't hide/show an icon button from the application bar. Any one tell me the answer if you have.
We can't access direclty the visibilty propety of application bar,and so other way is remove icon when u no need it and add it again when you need it.
To Remove first appicon,
ApplicationBar.Buttons.RemoveAt(0);
To Add,
ApplicationBarIconButton b = new ApplicationBarIconButton();
b.Text = i.ToString();
b.IconUri = new Uri("/Images/icon1.png", UriKind.Relative);
ApplicationBar.Buttons.Add(b);
You can either hide the whole application bar:
ApplicationBar.IsVisible = false
when you want to hide the appbar. Set it to true whenever you want to display it.
Else you can hide individual buttons by:
((ApplicationBarIconButton)ApplicationBar.Buttons[buttonIndex]).IsEnabled = false;
Hope it helps.
I am not clear about your question, which one you need. So I share you some options about applicationBar & Menu which I know.
Completely hide appBar from your application page.
C#
ApplicationBar.IsVisible = false;
XAML
<shell:ApplicationBar IsVisible = false; />
If want to minimized applicationBar
ApplicationBar.Mode = ApplicationBarMode.Minimized; // to minimize ApplicationBar.Mode = ApplicationBarMode.Default; //to get normal view
For disable
ApplicationBarIconButton _timerAppBarIconBtn; _timerAppBarIconBtn.IsEnabled = false;
Competely remove ApplicationBar & MenuItems
for (int i = ApplicationBar.Buttons.Count - 1; i >= 0; i--) ApplicationBar.Buttons.RemoveAt(i); for (int i = ApplicationBar.MenuItems.Count - 1; i >= 0; i--) ApplicationBar.MenuItems.RemoveAt(i);
Add ApplicationBar
ApplicationBarIconButton _timerAppBarIconBtn; _timerAppBarIconBtn = new ApplicationBarIconButton { IconUri = new Uri("/Assets/AppBar/timer.png", UriKind.Relative), Text = "timer" }; _timerAppBarIconBtn.Click += (s, v) => MaintainTimer(); //call a method ApplicationBar.Buttons.Add(_rotateAppBarIconBtn);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.