Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Await a button click

I use C#. I want to make a method that will do some stuff and then wait for the user to click one of four buttons. I want something similar to the MessageDialog async method that waits the user to click in this case, "Yes" or "No":

private  async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    var x = new MessageDialog("Yes or no?", "Choose");

    x.Commands.Add(new UICommand("Yes", (UICommandInvokeHandler) =>
        {
            // blabla
        }));
    x.Commands.Add(new UICommand("No", (UICommandInvokeHandler) =>
        {
            // blabla
        }));

    await x.ShowAsync();
}

The problem is that I can't use this method (MessageDialog) because I want 4 options but MessageDialog is up to 3.

EDIT:

private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    // doing some stuff
    Method();
    // doing some other stuff
}

private void Method()
{
    // makes everything in UI invisible
    // then makes the four buttons that were previously invisible, //visible
    // here I want the program to stop and wait the user to press one of //the four buttons
    // and then make the UI visible and the 4 buttons invisibl
}
like image 979
user2975038 Avatar asked Mar 22 '26 15:03

user2975038


1 Answers

Message Dialog represents a dialog in the WinRT framework. It supports only 3 buttons to make it usable on smaller screens. You have no other WinRT options. You can however create your own "dialog like" UI control, but i wouldn't recommend it. Maybe You can split your users decisions to 2 message dialogs.

like image 172
i3arnon Avatar answered Mar 25 '26 03:03

i3arnon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!