我想弄清楚如果一個oauth頁面已加載。wp7 c#LoadCompleted沒有射擊
所以我讓我的網頁瀏覽器導航到:
"https://api.munzee.com/oauth?response_type=code&client_id=" + API.ClientID + "&redirect_uri=" + API.RedirectUri;
其重定向率先 「https://api.munzee.com/oauth/signin」 顯示一個簡單的公式推這樣的:
<html>
<body>
<img src='https://static-cdn-munzee.netdna-ssl.com/images/munzee-logo.svg' style='width: 160px;'/>
<p>
The application <strong>my WP7 App</strong> would like to access your munzee.com player account.<br/>
This application won't be able to access or store your login credentials in any way.<br/>
Authorization for this application can be revoked at any time by visiting <a href='http://www.munzee.com/revoke'>http://www.munzee.com/revoke</a>.
</p>
<p><strong>Please sign in:</strong></p>
<form method='POST'>
<p>Username:<br/><input type='text' name='username'/></p>
<p>Password:<br/><input type='password' name='password'/></p>
<p><input type='submit' value='Login'/></p>
</form>
</body>
</html>
但LoadCompleted事件不火,一旦文件加載(我可以看到頁面成功加載在瀏覽器中)。該導航事件觸發就好了......
這裏是我到目前爲止的代碼:
private void LoginButton_Click(object sender, RoutedEventArgs e)
{
BackGroundBrowser.Navigate(
new Uri("https://api.munzee.com/oauth?response_type=code&client_id=" +
API.ClientID + "&redirect_uri=" + API.RedirectUri, UriKind.Absolute)
);
}
private void BackGroundBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
MessageBox.Show("BackGroundBrowser_LoadCompleted: " + BackGroundBrowser.Source.ToString());
// do some smart things...
}
private void BackGroundBrowser_Loaded(object sender, RoutedEventArgs e)
{
BackGroundBrowser.Navigate(new Uri("about:blank", UriKind.Absolute));
}
private void BackGroundBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
MessageBox.Show("BackGroundBrowser_Navigated: " + BackGroundBrowser.Source.ToString());
}
如果你有興趣這個主題,讓我知道,我會爲你提供我的clientID的和redirectUri爲測試目的。但我不想讓這些信息公開。
爲什麼會發生這種情況,是否有方法可以確定頁面是否已加載?我現在唯一的想法是在「導航」處理程序中創建一個循環,檢查一些與頁面相關的值,並在條件匹配時手動觸發事件。
但是,這似乎有點模糊,因爲這個頁面可以改變,我不想每次他們更新應用程序,例如,改變一些風格...
http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.loadcompleted(v=vs.95).aspx 「頂級導航時出現財產來源被調用 如果發生錯誤,例如無法找到內容,則當從Web服務器返回錯誤時,會引發LoadCompleted事件...有關處理事件的更多信息,請參閱事件概述Silverlight的「。 – H4mst0R 2014-10-30 21:02:59