Show software menu programmatically (wp7)

I have wp7 with some buttons on the application bar. When each button is pressed, I change the menu items of the application bar menu. After that, I want to automatically open the menu when I click the application panel button.

But it looks like the SDK is not letting me do this.

Do you know any work?

I thought if it’s impossible above to simulate a click of a user’s finger in the lower right corner of the screen to open the menu. Any ideas on this?

Thanx in advance

+3
source share
2 answers

, . -, , , . connect (vs/wpdt).

+2

, .

( ) .

, . , , , .

, :

public partial class MainPage : PhoneApplicationPage
{
    private ApplicationBar appbar;
    public MainPage()
    {
        InitializeComponent();
        Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        appbar = new ApplicationBar();

        var ib1 = new ApplicationBarIconButton(new Uri("/images/one.png", UriKind.Relative)) { Text = "Option one" };
        ib1.Click += new EventHandler(ShowMenuOption1);

        var ib2 = new ApplicationBarIconButton(new Uri("/images/two.png", UriKind.Relative)) { Text = "Option two" };
        ib2.Click += new EventHandler(ShowMenuOption2);

        appbar.Buttons.Add(ib1);
        appbar.Buttons.Add(ib2);

        // Show menu option 1 as default
        DisplayMenuOption1();

        this.ApplicationBar = appbar;
    }

    private void DisplayMenuOption1()
    {
        appbar.MenuItems.Clear();

        var itemA = new ApplicationBarMenuItem("AAAA");
        var itemB = new ApplicationBarMenuItem("BBB");

        appbar.MenuItems.Add(itemA);
        appbar.MenuItems.Add(itemB);
    }

    private void DisplayMenuOption2()
    {
        appbar.MenuItems.Clear();

        var itemC = new ApplicationBarMenuItem("CCCC");
        var itemD = new ApplicationBarMenuItem("DDDD");

        appbar.MenuItems.Add(itemC);
        appbar.MenuItems.Add(itemD);
    }

    private void ShowMenuOption2(object sender, EventArgs e)
    {
        DisplayMenuOption2();
    }

    private void ShowMenuOption1(object sender, EventArgs e)
    {
        DisplayMenuOption1();
    }
}
+5

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


All Articles