Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how can we enable or disable the application bar buttons using C# code. like for some condition I want the app bar button to be enabled and for some disable. i tried doing appbutton1.IsEnabled = false; but this way it gives an exception. Any other way to do it.??
Posted

1 solution

The application bar consists of a Buttons collection and MenuItems collection.Try something like..
C#
foreach (var button in ApplicationBar.Buttons)
{
    ((ApplicationBarIconButton) button).IsEnabled = false; // disables the button
}

ApplicationBar.IsMenuEnabled = false; // this will prevent menu from opening
 
Share this answer
 
Comments
Nikhil_Malik 29-Jul-13 15:06pm    
thanx dude. Its working fyn now. can you help me with dhis also please : http://www.codeproject.com/Questions/628136/Windows-Phone-8-Development
ridoy 29-Jul-13 15:13pm    
glad to help you,yes i'm working on it! :)
Nikhil_Malik 29-Jul-13 15:18pm    
It enables and disables all the buttons. If I want to enable or disable just 1 button what should I change.???
Nikhil_Malik 29-Jul-13 15:51pm    
please let me know if you find a sol to disable each app button individually
ridoy 29-Jul-13 15:57pm    
you can use IsEnabled=false property to disable a button or ApplicationBar.Buttons.Remove(object).See more from here:http://stackoverflow.com/questions/13287034/set-visibility-of-applicationbariconbutton-to-false-in-wp7

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900