如何在Mahapps中获取ShowInputAsync对话框的结果

时间:2017-02-27 13:02:41

标签: c# .net wpf xaml mahapps.metro

ShowInputAsync()返回一个字符串,但我想从对话框中得到结果,我的意思是肯定或取消。

1 个答案:

答案 0 :(得分:4)

如果返回 null ,则表示用户点击取消

    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

相关问题