无法在xamarin cross plateform应用程序中导航 [英] Unable to navigate in xamarin cross plateform application

查看:127
本文介绍了无法在xamarin cross plateform应用程序中导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xamarin cross plateform应用程序,并且在这个域中新建一个,必须争用页面登录,而主页面,点击登录用户后必须重定向到主页面。这是代码。



问题是点击登录按钮,并通过异常调试代码,



只有创建视图层次结构的原始线程才能触及其视图



谷歌但没有解决方案是富有成效的。



我尝试过:



I am working in xamarin cross plateform application,and new one in this domain,have to contend page Login,and main page,after clicking on login user must redirect to main page. here is the code.

Problem is when login button is clicked,and debug the code its through exception,

only the original thread that created a view hierarchy can touch its views

did google but no solution was fruitful.

What I have tried:

App.cs
 
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new Login());
}
 
Login.cs
 
async void _client_ValidateUserCompleted(object sender, FypWcf.ValidateUserCompletedEventArgs e)
{
try
{
if (e.Result == true)
{
await Navigation.PushAsync(new MainForm());
}
else
{
await DisplayAlert("Oops", "Credentials are incorrect", "Cancel");
}
}
catch (Exception ex)
{
await DisplayAlert(ex.Message, "Credentials are incorrect", "Cancel");
}
}
private void Button_Clicked_1(object sender, EventArgs e)
{
try
{
var endpoint = new EndpointAddress("http://192.168.43.101/FYP_Admin/webservices/cmsservice.svc");
var binding = new BasicHttpBinding
{
Name = "basicHttpBinding",
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
TimeSpan timeout = new TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
_client = new FypWcf.CMSServiceClient(binding, endpoint);
string username = usernameEntry.Text.Trim();
string password = passwordEntry.Text.Trim();
_client.ValidateUserAsync(username, password);
_client.ValidateUserCompleted += _client_ValidateUserCompleted;
}
catch (Exception ex)
{
DisplayAlert(ex.Message, "Credentials are incorrect", "Cancel");
}
}

推荐答案

await Navigation.PushAsync(new MainForm());

)删除等待并尝试


这篇关于无法在xamarin cross plateform应用程序中导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆