wp7 c#装载完成未点火
我试图弄清楚oauth页面是否已加载 因此,我让我的webbrowser导航到:wp7 c#装载完成未点火,c#,events,windows-phone-7,oauth,C#,Events,Windows Phone 7,Oauth,我试图弄清楚oauth页面是否已加载 因此,我让我的webbrowser导航到: ”https://api.munzee.com/oauth?response_type=code&client_id=“+API.ClientID+”&redirect_uri=“+API.RedirectUri 它首先重定向到“”显示如下简单公式: <html> <body> <img src='https://static-cdn-munzee.netdna-ssl.com
”https://api.munzee.com/oauth?response_type=code&client_id=“+API.ClientID+”&redirect_uri=“+API.RedirectUri代码>
它首先重定向到“”显示如下简单公式:
<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>
如果您对这个主题感兴趣,请告诉我,我将为您提供我的clientID和redirectUri,以供测试之用。但我不想让这些信息公开
为什么会发生这种情况?有没有办法确定页面是否已加载?现在我唯一的想法是在“导航”处理程序中创建一个循环,检查一些与页面相关的值,并在条件匹配时手动触发事件
但这似乎有点模糊,因为这个页面可以更改,我不想每次都更新应用程序,例如更改一些样式…加载的事件指的是WebBrowser
控件。当控件加载到可视化树中时,将触发该命令
它与浏览器中的DOMLoad事件不同
没有触发与DOM加载事件等效的事件。
最接近的方法是监视导航的事件,然后在访问页面内容之前稍等片刻。
请注意,您需要等待导航的事件将在页面完成“加载”之前触发。这是在浏览器引擎完成内容布局以及页面上(或链接到页面上)的任何javascript运行之前。“当设置源属性或调用导航时,会发生顶级导航。如果发生错误,例如找不到内容,则从Web服务器返回错误时将引发LoadCompleted事件。。。有关处理事件的详细信息,请参阅Silverlight的事件概述。“
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());
}