我正在Silverlight 4中创建一个应用程序。用户接触的第一个屏幕是登录屏幕(Login.xaml)。我已经在Login.xaml.cs文件中编写了以下代码。
private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
//first validate if the user is authorised for this application
if (this.ValidateEntry())
{
if (UserAuthenticationBL.AuthenticateUser(txtUserName.Text.Trim(), txtPassword.Password.Trim()))
{
//since the user is authenticated we will show the dashboard screen
this.Content = new MainPage();
}
else
{
this.ShowErrorMessage("Invalid username or password");
txtUserName.Focus();
}
}
}
我的问题是在获取AuthenticateUser方法中的数据之前执行代码。代码会立即变为“无效的用户名或密码”,并在完成对xaml页面的所有执行之后加载列表。
我知道异步thingi有问题……我还知道我需要放置一个事件来知道加载何时完成。。。。。。。。
但我不知道该怎么办!!!
有人能帮我解释一下这个问题吗。。。
谢谢您。