Windows Phone disables application bar button

So what is my problem? I have a popup , and when I open it, I want to disable the current page in applications for Windows phones. so I do this this.IsEnabled = false; But my ApplicationBar is still available. Of course I try:

 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 no result yet. I am sure that some of them are done earlier, can you show me how?

+4
source share
5 answers

The application panel consists of a collection of buttons and a collection of MenuItems. For your example, you would like 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 does not work, do you think you are hiding the application bar?
ApplicationBar.IsVisible = false;

+14
source

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 this works because I have code that uses it in a Windows Phone 8 app

Can you post a code for us to see, please

+3
source

Unfortunately, according to this post , there is an error which means that setting the IsEnabled property for ApplicationBarMenuItem does not deserve until the menu is closed and open.

+2
source

Just enable the use of Microsoft.Phone.Shell to pick up the namespace in 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

0
source

try the following:

XAML:

 <shell:ApplicationBar IsVisible="False"> 

.cs

 Dispatcher.BeginInvoke(() => { UIHelper.ToggleVisibility(Canvas_LocationAR_Trans); UIHelper.ToggleVisibility(Grid_LocARLoadingGrid); **ApplicationBar.IsVisible = true;** }); 
0
source

Source: https://habr.com/ru/post/1438019/


All Articles