【发布时间】:2019-11-12 01:25:39
【问题描述】:
我有一个视图模型,代码如下:
public async Task StopBtnAsync()
{
CancelSpeech();
App.pauseCard = true;
if (Settings.mode == MO.Learn)
StopLearn();
if (Settings.mode == MO.Practice)
StopPractice();
if (Settings.mode == MO.Quiz)
{
if (await DisplayAlert("Stop Quiz " + Settings.quiz, "Please confirm", "OK", "Cancel") == true)
StopQuiz();
}
}
单击停止按钮会尝试显示 DisplayAlert 进行确认。
但 DisplayAlert 在 IDE 中显示为红色,并显示一条消息,指出它在当前上下文中不存在。
注意,我尝试将其更改为:App.Current.MainPage.DisplayAlert 但这仍然不起作用。可能是因为这是一个 shell 应用程序。
谁能告诉我如何解决这个问题。
参考:
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new AppShell();
}
【问题讨论】:
标签: xamarin xamarin.forms