0
我想在App.xaml.cs類中進行身份驗證,如果用戶存在於數據庫中,我想將用戶引導至成員頁面,否則要直接將用戶公開頁。我知道如何使用根框架導航,但問題是即使我的webervice異步方法是在RootFrameNavigating它之前未執行的情況下編寫的。 我的代碼是在這裏在RootFrame.Navigating事件之前執行webservice方法windows phone 7
在應用程序構造
dclient.GetUserByPhoneIdCompleted += new EventHandler<GetUserByPhoneIdCompletedEventArgs> (dclient_GetUserByPhoneIdCompleted);
dclient.GetUserByPhoneIdAsync(GetDeviceUniqueID());
if (getUserbyPhoneIdCompleted)
RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating);
,並在我的方法
if (e.Uri.ToString().Contains("/MainPage.xaml") != true)
return;
e.Cancel = true;
RootFrame.Dispatcher.BeginInvoke(delegate
{
if (userId == -1)
RootFrame.Navigate(new Uri(string.Format("/View/PublicPage.xaml"), UriKind.Relative));
else
RootFrame.Navigate(new Uri(string.Format("/View/WelcomePage.xaml"), UriKind.Relative));
});
,並在我的web服務方法的整數返回,我得到的用戶ID有
像此
void dclient_GetUserByPhoneIdCompleted(object sender, GetUserByPhoneIdCompletedEventArgs e)
{
userId = e.Result;
getUserbyPhoneIdCompleted = true;
}
如果啓動頁面沒有得到加載quickliy,該應用程序不會通過市場認證。避免在此之前進行此認證。 – TutuGeorge