0
我在WPF Web瀏覽器如何使用WPF caliburn.micro
<WebBrowser x:Name="WebBrowserControl" Width="1000" Height="600" Source="https://www.1.com" cal:Message.Attach="[Event LoadCompleted]=[Action LoadCompleted($eventArgs)]"/>
它加載搶webbrowser.document的www.1.com,當我點擊1.com一個按鈕,它跳到http://2.com 我聽loadCompleted事件
public void LoadCompleted(NavigationEventArgs e)
{
if (e.Uri.AbsoluteUri == "https://www.2.com")
{
//Here i want to get WebBrowserControl.Document as mshtml.HTMLDocument;
MessageBox.Show("Completed loading the page");
}
}
我想2.com HTMLDocument的。有沒有辦法做到這一點。我以非視角模式實現這一點。
private void WebBrowserControl_LoadCompleted(object sender, NavigationEventArgs e)
{
string[] tags = new string[]{};
if (e.Uri.OriginalString == "https://www.2.com")
{
MessageBox.Show("here");
var document = WebBrowserControl.Document as mshtml.HTMLDocument;
}
}
我做了這樣的事情
//view
cal:Message.Attach="[Event LoadCompleted]=[Action LoadCompleted(WebBrowserControl.Document,$eventArgs)]"
//ViewModel
public void LoadCompleted(mshtml.HTMLDocument x ,NavigationEventArgs e)
{
//it calls this method but the x is null
}