Ragnarokkr Xia
Ragnarokkr Xia

Reputation: 303

How to get the result of ShowInputAsync Dialog in Mahapps

The ShowInputAsync() returns a string, but I want to get the result, I mean Affirmation or Cancellation, from the Dialog.

Upvotes: 6

Views: 1974

Answers (1)

jsanalytics
jsanalytics

Reputation: 13188

If it returns null, it means the user hit Cancel:

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        var result = await this.ShowInputAsync("Test", "Enter string:");

        if (result == null)
            return;

        await this.ShowMessageAsync("Test", "You entered " + result + "!");
    }

enter image description here

Upvotes: 7

Related Questions