I am building an UWP app (C#) and on click of button, I want to verify input. If verification fails, I want to display a message saying that there is wrong input. this is my function which should handle this:
private async void AddContact_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
DBHelper db = new DBHelper();
if(i_name.Text != "" && i_phone.Text != "") {
db.insertPerson(new Person(i_name.Text, i_phone.Text));
Frame.Navigate(typeof(MainPage));
} else {
ContentDialog msg = new ContentDialog() {
Title = "Empty input!",
Content = "Please fill both fields!",
CloseButtonText = "OK"
};
await msg.ShowAsync();
}
}
However, when the last part (await msg.showAsync() ) is typed it stays underlined in red (in VS). The builder reads the following error:
Error CS4036 'IAsyncOperation' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation' could be found (are you missing a using directive for 'System'?) testniStudioApp d:...\SecondPage.xaml.cs 43 Active
Now i tried to assign this call to variable (as I saw that someone solved similiar problem that way), but it still didn't worked. Then I tried clearing NuGet cache and rebuilding project as stated here, but none of those solutions worked.
I have a hard time understanding what it wants from me. Every single tutorial on how to display message was written in more or less the same manner, so I can't understand what can be wrong.
using System;
was mising.
Thanks to comments for answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With