显示警报名称在当前上下文中不存在?

时间:2017-11-20 22:19:20

标签: xamarin

我不知道为什么DisplayAlert不起作用,如果我写page.Displayalert它也不起作用

使用System;

使用Xamarin.Forms;

使用UIKit;

命名空间test.project {     public partial class ViewController:UIViewController     {

    partial void UIButton197_TouchUpInside(UIButton sender)
    {
        if(textBoxName.Text == "" && textBoxpasswd.Text == "")
        {
            await displayAlert("Hello");
        }


    }

    protected ViewController(IntPtr handle) : base(handle)
    {
        // Note: this .ctor should not contain any initialization logic.
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        // Perform any additional setup after loading the view, typically from a nib.
    }

    public override void DidReceiveMemoryWarning()
    {
        base.DidReceiveMemoryWarning();
        // Release any cached data, images, etc that aren't in use.
    }
}

}

2 个答案:

答案 0 :(得分:3)

就像Jason所说,是Page上的方法,但如果你真的需要,你可以试试这个:

await App.Current.MainPage.DisplayAlert ("Hello", "No");

答案 1 :(得分:0)

displayAlert。这应该是DisplayAlert。部分void UIButton197_TouchUpInside应该是异步的。