Windows phone disable application bar button

Swift Sharp picture Swift Sharp · Oct 5, 2012 · Viewed 8.6k times · Source

So, what is my problem ? I have a popup, and when i open it, i want to disable current page in my windows phone applications. so i make this this.IsEnabled = false; But my ApplicationBar is still available. Of course i try with:

ApplicationBar.IsMenuEnabled = false;

My next idea was to do something like this:

for (int i = 0; i < ApplicationBar.MenuItems.Count; i++)
{
    ((ApplicationBarMenuItem)ApplicationBar.Buttons[i]).IsEnabled = false;
}

and still no result. I'm sure that some is done that before, can you show me how?

Answer

earthling picture earthling · Oct 6, 2012

The application bar consists of a Buttons collection and MenuItems collection. For your example you would want to try something like

foreach (var button in ApplicationBar.Buttons)
{
    ((ApplicationBarIconButton) button).IsEnabled = false; // disables the button
}

ApplicationBar.IsMenuEnabled = false; // this will prevent menu from opening

if this isn't working, have you considered hiding the App bar?
ApplicationBar.IsVisible = false;