Issue
I'm trying to implement a simple Dialog with a text input in Android Xamarin, using a DisplayPromptAsync:
private async void ShowDialogAsync() {
string result = await DisplayPromptAsync("Question 1", "What's your name?");
}
Source: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/pop-ups
But I'm getting the next error:
CS0103 The name 'DisplayPromptAsync' does not exist in the current context
And it doesn't give me the option to import any library. My version of Xamarin Forms is 4.6.0.726
It's something I'm missing...?
Thanks in advance...
Solution
In the ViewModel, just add the App.Current.MainPage before the call of DisplayPromptAsync:
private async void ShowDialogAsync() {
string result = await App.Current.MainPage.DisplayPromptAsync("Question 1", "What's your name?");
// OK
if (result != null)
{
// do something here
} else {
// do something else here
}
}
Thanks to Jason for his reply...
Answered By - CyborgNinja23
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.