Search code examples
c#windows-phone-8windows-phonecode-behind

Open Windows Phone ApplicationBar from code-behind


Is there an official way or trick to open the Windows Phone ApplicationBar using C# from the code-behind? I'd like to show my users additional options hidden in the menu.

To be clear, I don't need to create the menu in code-behind (but can, if that helps in any way).


Solution

  • There are no way to open application bar programmatically. But you can create application bar in C#. Here is the sample.

    ApplicationBar = new ApplicationBar();
        ApplicationBar.Mode = ApplicationBarMode.Default;
        ApplicationBar.Opacity = 1.0; 
        ApplicationBar.IsVisible = true;
        ApplicationBar.IsMenuEnabled = true;
    
        ApplicationBarIconButton button1 = new ApplicationBarIconButton();
        button1.IconUri = new Uri("/Images/YourImage.png", UriKind.Relative);
        button1.Text = "button 1";
        ApplicationBar.Buttons.Add(button1);
    
        ApplicationBarMenuItem menuItem1 = new ApplicationBarMenuItem();
        menuItem1.Text = "menu item 1";
        ApplicationBar.MenuItems.Add(menuItem1);