1

i'm trying to manipulate buttons in my app bar with the proprety enabled and disabled but every time i got an exception telling me System access violation!! any idea about what's going on

 <phone:PhoneApplicationPage.ApplicationBar >
    <shell:ApplicationBar IsMenuEnabled="True" BackgroundColor="#989898"    ForegroundColor="White">
        <shell:ApplicationBarIconButton IconUri="/Images/APPBAR/Mes-infos-personnelles copie.png" x:Name="Profile_Button" IsEnabled="True" Text="Profile" />

        <shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarMenuItem   Text="Box" />

        </shell:ApplicationBar.MenuItems>

    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

and in my code behind :

Profile_Button.IsEnabled = false;//exception here 

1 Answers1

0

try this

((ApplicationBarIconButton) ApplicationBar.Buttons[0]).IsEnabled = false; // disables Profile_Button button

//disable all buttons and menu item in from app bar

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

       //To prevent the menu from opening you have to use this code:
       ApplicationBar.IsMenuEnabled = false;
Jaihind
  • 2,770
  • 1
  • 12
  • 19