Xamarin.Forms - Android 上不支持全局 PushAsync,请使用 NavigationPage
Xamarin.Forms - PushAsync is not supported globally on Android, please use a NavigationPage
我正在尝试做的是在用户注册后,他们单击是,它将转到登录页面。否则用户单击 "Cancel" 它将进行注册,请帮助我..我是 xamarin
的新手
void Handle_Clicked(object sender, System.EventArgs e)
{
string ConnectionString = "Server=10.0.2.2; Port=5432;User Id=postgres; Password=ncf123; Database=Accounting";
try
{
NpgsqlConnection connection = new NpgsqlConnection(ConnectionString);
connection.Open();
}
catch (Exception)
{
Console.WriteLine("adi na");
}
NpgsqlConnection connections = new NpgsqlConnection(ConnectionString);
connections.Open();
NpgsqlCommand command = connections.CreateCommand();
command.CommandText = "INSERT INTO account(username, password, email, phonenumber) VALUES ( '" + EntryUsername.Text + "', '" + EntryPassword.Text + "','" + EntrEmail.Text + "','" + EntryPhoneNumber.Text + "')";
try
{
NpgsqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
EntryUsername.Text = reader[0].ToString();
EntryPassword.Text = reader[1].ToString();
EntrEmail.Text = reader[2].ToString();
EntryPhoneNumber.Text = reader[3].ToString();
}
connections.Close();
Device.BeginInvokeOnMainThread(async () =>
{
var result = await DisplayAlert("Congratulations", "User Registration Successfull", "Yes", "Cancel");
if (result)
{
await Navigation.PushAsync(new LoginPage());
}
else
{
await Navigation.PushAsync(new registration());
}
});
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
更新
这是我的 App.xaml.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new registration();
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
请大家帮帮我,我是 xamarin 和 postgresql 的新手
在您的 app.cs 中更改 MainPage = new MainPage();到 MainPage = new NavigationPage(new MainPage());
其中 MainPage() 是您在启动应用程序时要打开的页面的名称
我正在尝试做的是在用户注册后,他们单击是,它将转到登录页面。否则用户单击 "Cancel" 它将进行注册,请帮助我..我是 xamarin
的新手 void Handle_Clicked(object sender, System.EventArgs e)
{
string ConnectionString = "Server=10.0.2.2; Port=5432;User Id=postgres; Password=ncf123; Database=Accounting";
try
{
NpgsqlConnection connection = new NpgsqlConnection(ConnectionString);
connection.Open();
}
catch (Exception)
{
Console.WriteLine("adi na");
}
NpgsqlConnection connections = new NpgsqlConnection(ConnectionString);
connections.Open();
NpgsqlCommand command = connections.CreateCommand();
command.CommandText = "INSERT INTO account(username, password, email, phonenumber) VALUES ( '" + EntryUsername.Text + "', '" + EntryPassword.Text + "','" + EntrEmail.Text + "','" + EntryPhoneNumber.Text + "')";
try
{
NpgsqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
EntryUsername.Text = reader[0].ToString();
EntryPassword.Text = reader[1].ToString();
EntrEmail.Text = reader[2].ToString();
EntryPhoneNumber.Text = reader[3].ToString();
}
connections.Close();
Device.BeginInvokeOnMainThread(async () =>
{
var result = await DisplayAlert("Congratulations", "User Registration Successfull", "Yes", "Cancel");
if (result)
{
await Navigation.PushAsync(new LoginPage());
}
else
{
await Navigation.PushAsync(new registration());
}
});
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
更新 这是我的 App.xaml.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new registration();
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
请大家帮帮我,我是 xamarin 和 postgresql 的新手
在您的 app.cs 中更改 MainPage = new MainPage();到 MainPage = new NavigationPage(new MainPage()); 其中 MainPage() 是您在启动应用程序时要打开的页面的名称