Search code examples
c#xamlwindows-phone-8

How to hide/show the icon button from the application bar in windows phone 8 apps?


I am developing an application for windows phone 8. My problem is I could't hide/show an icon button from the application bar. Any one tell me the answer if you have.


Solution

  • We can't access direclty the visibilty propety of application bar,and so other way is remove icon when u no need it and add it again when you need it.

    To Remove first appicon,

    ApplicationBar.Buttons.RemoveAt(0);
    

    To Add,

    ApplicationBarIconButton b = new ApplicationBarIconButton();
    b.Text = i.ToString();
    b.IconUri = new Uri("/Images/icon1.png", UriKind.Relative);
    ApplicationBar.Buttons.Add(b);