4

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?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Swift Sharp
  • 2,604
  • 3
  • 30
  • 54

5 Answers5

14

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;

earthling
  • 5,084
  • 9
  • 46
  • 90
3

How about this

((ApplicationBarIconButton)this.ApplicationBar.Buttons[1]).IsEnabled = true;

Where [1] is the index of the button you want to enable/disable

I know for a fact this works as I have code that uses it in a Windows Phone 8 app

Can you post some code for us to see please

djack109
  • 1,261
  • 1
  • 23
  • 42
2

Unfortunately, according to this post there is a bug which means that setting the IsEnabled property of an ApplicationBarMenuItem does not get honoured until the menu is closed and re-opened.

Emil
  • 7,220
  • 17
  • 76
  • 135
Kevan
  • 45
  • 5
0

Just include the using Microsoft.Phone.Shell to pickup the namespace within your .cs file and you can do the following:

ApplicationBar.Enable();

and

ApplicationBar.Disable();

According to http://new.efficientcoder.net/2010/10/windows-phone-7-quick-tip-17.html

Guo Hong Lim
  • 1,690
  • 3
  • 13
  • 20
0

try this :

xaml:

<shell:ApplicationBar IsVisible="False">

.cs

Dispatcher.BeginInvoke(() =>
            {
                UIHelper.ToggleVisibility(Canvas_LocationAR_Trans);
                UIHelper.ToggleVisibility(Grid_LocARLoadingGrid);
                **ApplicationBar.IsVisible = true;**
            });
Ankit
  • 113
  • 1
  • 9